android service onBind SecurityException
Posted
by
Metalex
on Stack Overflow
See other posts from Stack Overflow
or by Metalex
Published on 2012-11-19T16:57:27Z
Indexed on
2012/11/19
16:59 UTC
Read the original article
Hit count: 602
I don't know why but in some devices my service isn't allowed to bind.
java.lang.RuntimeException: Unable to create application mypackage.MyApplication: java.lang.SecurityException: Unable to find app for caller android.app.ApplicationThreadProxy@41680e78 (pid=16805) when binding service Intent { cmp=mypackage/.MyService }
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4394)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.SecurityException: Unable to find app for caller android.app.ApplicationThreadProxy@41680e78 (pid=16805) when binding service Intent { cmp=mypackage/.MyService }
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.app.ActivityManagerProxy.bindService(ActivityManagerNative.java:2720)
at android.app.ContextImpl.bindService(ContextImpl.java:1431)
at android.app.ContextImpl.bindService(ContextImpl.java:1407)
at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
at mypackage.MyApplication.openService(MyApplication.java:151)
at mypackage.MyApplication.onCreate(MyApplication.java:110)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1000)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4391)
... 10 more
java.lang.SecurityException: Unable to find app for caller android.app.ApplicationThreadProxy@41680e78 (pid=16805) when binding service Intent { cmp=mypackage/.MyService }
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.app.ActivityManagerProxy.bindService(ActivityManagerNative.java:2720)
at android.app.ContextImpl.bindService(ContextImpl.java:1431)
at android.app.ContextImpl.bindService(ContextImpl.java:1407)
at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
at mypackage.MyApplication.openService(MyApplication.java:151)
at mypackage.MyApplication.onCreate(MyApplication.java:110)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1000)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4391)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Code from MyApplication:
@Override
public void onCreate() {
super.onCreate();
openService();
}
public void openService() {
Intent service = new Intent(this, MyService.class);
mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IMyService.Stub.asInterface(service);
if (mListener != null) {
mListener.onServiceStarted(mService);
}
}
@Override
public void onServiceDisconnected(ComponentName cn) {
mService = null;
}
};
bindService(service, mConnection, Context.BIND_AUTO_CREATE); // 151 line
}
Please help me! Thank you!
© Stack Overflow or respective owner