두 개의 Android 애플리케이션, 권한 제공자 및 요청자가 있습니다.Android 권한 - 모범 사례
내가이를 실행 할 수있는 권한이 없습니다 런처로 실행 가능한 활동에 대한 사용 권한을 설정하는 잘못된 희망
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.permissionprovider"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission android:description="@string/permission_desc"
android:icon="@drawable/ic_launcher"
android:label="some permission"
android:name="com.example.permissionprovider.CUSTOM"
android:protectionLevel="normal" />
<!-- is the below tag required in the provider?-->
<uses-permission android:name="com.example.permissionprovider.CUSTOM"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.permissionprovider.MainActivity"
android:permission="com.example.permissionprovider.CUSTOM"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
는 것이 올바른 아래 매니페스트 activity.Is 공급자가있다?
공급자의 매니페스트가 공급자 응용 프로그램에 com.example.permissionprovider.CUSTOM 권한이 필요하다고 선언해야합니까? 그렇지 않으면 동일한 매니페스트에 사용 권한이 정의되어 있으므로 필요하지 않습니까?
는 지금은
매니페스트 아래<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.permissionrequester"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="com.example.permissionprovider.CUSTOM"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.permissionrequester.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
을 가지고 요청자 응용 프로그램이 있고 신청인은 공급자의 활동을 시작하려고합니다. 공급자 응용 프로그램이 설치 먼저 요청에 의해 다음 경우
Intent i;
PackageManager manager = getPackageManager();
try {
i = manager.getLaunchIntentForPackage("com.example.permissionprovider");
if (i == null)
throw new PackageManager.NameNotFoundException();
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
} catch (PackageManager.NameNotFoundException e) {
} }
- 는 다음 요청은 공급자의 활동을 시작할 수 있지만 먼저 설치되어있는 요청자의 경우이 발생하지 않습니다. 이 문제를 어떻게 해결할 수 있습니까?
감사합니다. :). 두 앱에 을 추가하면 마지막 문제가 해결되었습니다. 나는 2 번 질문으로 나는 분명하지 않다라고 생각한다.요청자가 동일한 권한으로 보호되는 일부 구성 요소를 가지고 공급자가 해당 구성 요소를 활성화하려고 시도하지 않는 한 이 요청자에서만 필요하며 공급자에서는 필요하지 않기를 바랍니다. –
coderplus