1.有访问权限的activity的定义端
1.1定义权限
<permission android:name="com.example.f6k5i8.checkpermission.permission.MyAty" />
1.2为组件指定权限
1 <activity 2 android:name=".MyAty" 3 android:permission="com.example.f6k5i8.checkpermission.permission.MyAty" 4 android:label="@string/title_activity_my_aty" > 5 <intent-filter > 6 <category android:name="android.intent.category.DEFAULT" /> 7 <action android:name="com.example.f6k5i8.checkpermission.intent.action.MyApp" /> 8 </intent-filter> 9 </activity>
2.有访问权限的activity的访问端
2.1minifest.xml
- 在同app中不用声明权限
<uses-permission android:name="com.example.f6k5i8.checkpermission.permission.MyAty" />
- 在其它app中要声明权限
<uses-permission android:name="com.example.f6k5i8.checkpermission.permission.MyAty" />
2.2 代码
1 findViewById(R.id.btnStartMyAty).setOnClickListener(new View.OnClickListener() { 2 @Override 3 public void onClick(View v) { 4 Intent i = new Intent("com.example.f6k5i8.checkpermission.intent.action.MyApp"); 5 startActivity(i); 6 } 7 });
转载于:https://www.cnblogs.com/sjjg/p/4512654.html