0
我正在開發一個android應用程序。當我想開始一項服務時,我面臨這個問題:不允許綁定到服務意圖。該服務是Yotaphone後臺屏幕服務。不允許綁定到服務啓動服務時的意圖
我搜索的問題,有很少的信息,他們大多數不是同一類問題。我不知道哪個部分出了問題。
我同道說明: http://mwiki.yotaphone.com/wiki/Building_First_App。
的調用onStart()函數在MainActivity:
@Override
protected void onStart() {
super.onStart();
Intent bsIntent = new Intent(this, MyBSActivity.class);
this.startService(bsIntent);
}
的Yotaphone背面屏幕服務:
public class MyBSActivity extends BSActivity {
@Override
protected void onBSCreate() {
super.onBSCreate();
setBSContentView(R.layout.bs_activity);
}}
錯誤描述:
04-24 18:27:12.659 28763-28763/com.pli.yotaphone2 E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.pli.yotaphone2, PID: 28763
java.lang.RuntimeException: Unable to start service [email protected] with Intent { cmp=com.pli.yotaphone2/.MyBSActivity }: java.lang.SecurityException: Not allowed to bind to service Intent { act=yotaphone.intent.action.GET_SDK_BINDER }
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2735)
at android.app.ActivityThread.access$2100(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5061)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.SecurityException: Not allowed to bind to service Intent { act=yotaphone.intent.action.GET_SDK_BINDER }
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1596)
at android.app.ContextImpl.bindService(ContextImpl.java:1560)
at android.content.ContextWrapper.bindService(ContextWrapper.java:517)
at com.yotadevices.sdk.BSActivity.doBindService(BSActivity.java:137)
at com.yotadevices.sdk.BSActivity.onStartCommand(BSActivity.java:173)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2718)
的AndroidManifest.xml中:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".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>
<!-- Service for working with a back screen -->
<service
android:name=".MyBSActivity"
android:exported="true" />
<!-- Adding YotaPhone SDK library -->
<uses-library
android:name="com.yotadevices.yotaphone2.sdk.v2"
android:required="true" />
</application>
非常感謝。這完全解決了我的問題! –
很高興爲您服務。請將此答案標記爲已接受,以便其他人也能看到。 – Jeopardy