0
當我嘗試從我的應用程序執行bindService時,出現以下錯誤。我正在使用Android源代碼,並且我相信我嘗試綁定的這個服務不是從別處開始的。我已經通過設置 - >應用程序 - >運行來證實這一點,它顯示正在運行的服務。bindservice期間的異常
01-02 00:06:54.531: INFO/PowerManagerService(425): Start Light.setBrightness(), [20], [3]
01-02 00:06:56.473: INFO/PowerManagerService(425): Start Light.setBrightness(), [130], [3]
01-02 00:06:58.055: WARN/dalvikvm(4956): threadid=1: thread exiting with uncaught exception (group=0x40b70390)
01-02 00:06:58.055: WARN/ActivityManager(425): Permission Denial: Accessing service ComponentInfo{jp.co.abc.android.omrsettings/jp.co.xyz.bluetooth.profile.TIPServer} from pid=4956, uid=10158 requires jp.co.abc.android.OMRSettings.permission.Access
01-02 00:06:58.065: ERROR/AndroidRuntime(4956): FATAL EXCEPTION: main
java.lang.SecurityException: Not allowed to bind to service Intent { act=jp.co.xyz.bluetooth.api.ITimeServer }
at android.app.ContextImpl.bindService(ContextImpl.java:1187)
at android.content.ContextWrapper.bindService(ContextWrapper.java:370)
at jp.co.abc.middleware.tip.LeTimeServerProfile.startTimeServer(LeTimeServerProfile.java:45)
at jp.co.abc.tip.TimeActivity.onClick(TimeActivity.java:49)
at android.view.View.performClick(View.java:3511)
at android.view.View$PerformClick.run(View.java:14133)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
at dalvik.system.NativeStart.main(Native Method)
01-02 00:06:58.095: WARN/ActivityManager(425): Force finishing activity jp.co.abc.tip/.TimeActivity
奇怪的是,當我從設備中刪除特定應用程序時,不會發生此錯誤。有人可以告訴我什麼可能是我的這個應用程序出現此錯誤的原因,而不是當我刪除此應用程序?
任何幫助,非常感謝。
編輯
這是我用做bindservice代碼:
mContext.bindService(new Intent("jp.co.xyz.bluetooth.api.ITimeServer"), time_connection, Context.BIND_AUTO_CREATE);
ServiceConnection time_connection = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service){
mTime = ITimeServer.Stub.asInterface(service);
try {
mTime.startTIPServer(callback,Constants.TIME_SOURCE_CELLULAR_NETWORK,46);
} catch (RemoteException e) {
Log.e(TAG, " startTIPServer error ");
}
}
public void onServiceDisconnected(ComponentName name){
mTime = null;
}
};
請添加您的代碼.... – user4232
添加代碼作爲編輯 – Anu