我的应用在Google Play上遇到问题.我有一个免费的应用程序,它使用自定义权限.此权限允许访问付费应用.这些付费应用程序充当"钥匙"并解锁免费应用程序中的功能.基本上,免费应用程序将尝试启动其中一个付费应用程序的意图.付费应用程序将执行一些操作并返回说明免费应用程序是否应该解锁功能.
根据应用安装的顺序出现问题.如果首先安装免费应用程序然后安装付费应用程序,则免费应用程序无法启动意图.返回权限拒绝.如果首先安装付费应用程序然后安装免费应用程序,免费应用程序可以启动意图没问题.重新启动设备和/或强制停止应用程序无法解决问题.我正在附上相关代码.有些东西告诉我,我做错了什么.
免费App Manifest(相关代码):
...
<uses-permission android:name="com.company.license.PERMISSION" />
...
Run Code Online (Sandbox Code Playgroud)免费应用程序代码检查意图(相关代码):
Intent KeyApp = new Intent("com.company.license.action.AUTH_1");
KeyApp.putExtra("com.company.license.challenge", 1);
//If free app is installed first, an exception is thrown for not having the proper permission. If paid app is installed first, no exception is thrown
try {
startActivityForResult(KeyApp, COMMING_FROM_KEYAPP);
} catch (Exception e) {
cancelStartUp();
}
Run Code Online (Sandbox Code Playgroud)付费应用清单(相关代码):
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.installer.1"
...
<permission
android:name="com.company.license.PERMISSION"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:protectionLevel="normal" >
</permission>
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoDisplay" >
<activity
android:name="com.company.license.auth"
android:configChanges="keyboardHidden|orientation"
android:exported="true"
android:permission="com.company.license.PERMISSION"
android:theme="@style/Theme.Transparent" >
<intent-filter> …Run Code Online (Sandbox Code Playgroud)java android android-manifest android-intent android-permissions
我写了一个获取天气的android服务,AndroidManifest.xml是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.weather"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service
android:name=".WeatherService"
android:exported="true" >
</service>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
现在,我想让另一个apk启动此服务:
Intent service = new Intent();
service.setClassName("com.my.weather", "com.my.weather.WeatherService");
context.bindService(service, weatherServiceConnection, Context.BIND_AUTO_CREATE);
Run Code Online (Sandbox Code Playgroud)
我收到了错误消息:
E/AndroidRuntime(14068): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.test/com.my.test.MainActivity}: java.lang.SecurityException: Not allowed to bind to service Intent { cmp=com.my.weather/.WeatherService }
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
其他apk是使用Messenger方法与气象服务进行通信.
================================================== ==============================
谢谢大家!
现在我修改我的气象服务的AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.weather"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher" …Run Code Online (Sandbox Code Playgroud)