我的 android 应用程序中有一项服务:
<service android:name="com.example.my.service.MyService" >
</service>
我在 build.gradle 中定义了两种风格:
defaultConfig {
applicationId "com.example.my"
}
productFlavors {
pro {
}
free {
applicationId = "com.example.my.free"
}
}
在com.example.my.MainActivity的onCreate中,我绑定了服务:
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.example.my", "com.example.my.service.MyService");
bindService(intent, mMyServiceconnection, BIND_AUTO_CREATE);
pro 应用程序可以成功运行并绑定服务。但是当免费应用尝试绑定服务时,出现错误:
java.lang.SecurityException: Not allowed to bind to service Intent { cmp=com.example.my/.service.MyService }
该服务只需要在应用程序内部访问,免费应用程序有什么方法可以绑定服务吗?