码迷,mamicode.com
首页 > 移动开发 > 详细

Android组件权限分配

时间:2016-06-22 21:44:38      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

技术分享技术分享技术分享技术分享

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 3     package="com.example.metrox.codepermission">
 4 
 5     <permission android:name="com.example.metrox.codepermission.permission.SAY_HELLO" />
 6     <permission android:name="com.example.metrox.codepermission.permission.myAty" />
 7     <uses-permission android:name="com.example.metrox.codepermission.permission.SAY_HELLO" />
 8 
 9     <application
10         android:allowBackup="true"
11         android:icon="@mipmap/ic_launcher"
12         android:label="组件权限分配"
13         android:supportsRtl="true"
14         android:theme="@style/AppTheme">
15         <activity android:name=".MainActivity">
16             <intent-filter>
17                 <action android:name="android.intent.action.MAIN" />
18 
19                 <category android:name="android.intent.category.LAUNCHER" />
20             </intent-filter>
21         </activity>
22         <activity android:name=".myAty"
23             android:label="被启动的Activity"
24             android:permission="com.example.metrox.codepermission.permission.myAty">
25             <intent-filter>
26                 <category android:name="android.intent.category.DEFAULT"></category>
27                 <action android:name="com.example.metrox.codepermission.intent.action.myAty"></action>
28             </intent-filter>
29         </activity>
30     </application>
31 
32 </manifest>
 1 <?xml version="1.0" encoding="utf-8"?>
 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 3     package="com.example.thesecend">
 4     <uses-permission android:name="com.example.metrox.codepermission.permission.myAty"></uses-permission>
 5     <application
 6         android:allowBackup="true"
 7         android:icon="@mipmap/ic_launcher"
 8         android:label="@string/app_name"
 9         android:supportsRtl="true"
10         android:theme="@style/AppTheme">
11         <activity android:name=".MainActivity">
12             <intent-filter>
13                 <action android:name="android.intent.action.MAIN" />
14 
15                 <category android:name="android.intent.category.LAUNCHER" />
16             </intent-filter>
17         </activity>
18     </application>
19 
20 </manifest>
 1 package com.example.thesecend;
 2 
 3 import android.content.Intent;
 4 import android.support.v7.app.AppCompatActivity;
 5 import android.os.Bundle;
 6 import android.view.View;
 7 
 8 public class MainActivity extends AppCompatActivity {
 9 
10     @Override
11     protected void onCreate(Bundle savedInstanceState) {
12         super.onCreate(savedInstanceState);
13         setContentView(R.layout.activity_main);
14         findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
15             @Override
16             public void onClick(View view) {
17                 startActivity(new Intent("com.example.metrox.codepermission.intent.action.myAty"));
18             }
19         });
20     }
21 }

 

Android组件权限分配

标签:

原文地址:http://www.cnblogs.com/linhongquan/p/5608379.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!