android - Permission in calling service from another app -


possible duplicates:

i have 2 applications app "a" , app "b". app has 1 service custom permission , app b wants call service. following code snippet

app a:: manifest file

  <service             android:name="sendservice"             android:permission="android.permission.myservice">             <intent-filter>                 <action android:name="com.example.calledactivity.myservicecaller" />                  <category android:name="android.intent.category.default" />                  <data android:scheme="sms" />                 <data android:scheme="smsto" />             </intent-filter>         </service> 

here have secured service using permission android.permission.myservice

in app b manifest file have following permission

<uses-permission android:name="android.permission.myservice"     android:description="@string/app_name"     android:label="@string/menu_settings" /> 

and call service of app a, using following code in app b

intent = new intent("com.example.calledactivity.myservicecaller", uri.parse("sms:2223333"));                     getapplicationcontext().startservice(i); 

when run sample getting securityexception following stack trace

12-05 23:35:41.526: w/dalvikvm(25730): threadid=1: thread exiting uncaught exception (group=0x40d3cac8) 12-05 23:35:41.526: w/activitymanager(752): permission denial: accessing service componentinfo{com.example.calledactivity/com.example.calledactivity.sendservice} pid=25730, uid=10159 requires android.permission.myservice 12-05 23:35:41.536: e/androidruntime(25730): fatal exception: main 12-05 23:35:41.536: e/androidruntime(25730): java.lang.securityexception: not allowed start service intent { act=com.example.calledactivity.myservicecaller dat=sms:xxxx } without permission android.permission.myservice 12-05 23:35:41.536: e/androidruntime(25730):    @ android.app.contextimpl.startserviceasuser(contextimpl.java:1714) 12-05 23:35:41.536: e/androidruntime(25730):    @ android.app.contextimpl.startservice(contextimpl.java:1686) 12-05 23:35:41.536: e/androidruntime(25730):    @ android.content.contextwrapper.startservice(contextwrapper.java:457) 12-05 23:35:41.536: e/androidruntime(25730):    @ com.example.callingactivity.mainactivity$1.onclick(mainactivity.java:29) 12-05 23:35:41.536: e/androidruntime(25730):    @ android.view.view.performclick(view.java:4383) 12-05 23:35:41.536: e/androidruntime(25730):    @ android.view.view$performclick.run(view.java:18097) 12-05 23:35:41.536: e/androidruntime(25730):    @ android.os.handler.handlecallback(handler.java:725) 12-05 23:35:41.536: e/androidruntime(25730):    @ android.os.handler.dispatchmessage(handler.java:92) 12-05 23:35:41.536: e/androidruntime(25730):    @ android.os.looper.loop(looper.java:137) 12-05 23:35:41.536: e/androidruntime(25730):    @ android.app.activitythread.main(activitythread.java:5279) 12-05 23:35:41.536: e/androidruntime(25730):    @ java.lang.reflect.method.invokenative(native method) 12-05 23:35:41.536: e/androidruntime(25730):    @ java.lang.reflect.method.invoke(method.java:511) 12-05 23:35:41.536: e/androidruntime(25730):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 12-05 23:35:41.536: e/androidruntime(25730):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 12-05 23:35:41.536: e/androidruntime(25730):    @ dalvik.system.nativestart.main(native method) 12-05 23:35:41.556: d/inputdispatcher(752): focused application set to: appwindowtoken{4231fa58 token=token{4231df58 activityrecord{4231dce8 u0 com.sec.android.app.launcher/com.android.launcher2.launcher}}} 12-05 23:35:41.556: w/activitymanager(752):   force finishing activity com.example.callingactivity/.mainactivity 12-05 23:35:41.576: w/contextimpl(752): calling method in system process without qualified user: android.app.contextimpl.sendbroadcast:1379 com.android.server.am.activitystack.startpausinglocked:1408 com.android.server.am.activitystack.finishactivitylocked:5920 com.android.server.am.activitystack.finishactivitylocked:5834 com.android.server.am.activitymanagerservice.handleappcrashlocked:9529  

i have gone through many of threads mentioned above, none of them able solve problem. so, have raised question again.

thanks

i think you're missing permission declaration in app manifest a.

http://developer.android.com/guide/topics/security/permissions.html see declaring , enforcing permissions.

also, if both apps signed , authored (with same signature) can declare them in both manifests order in installed doesn't affect this.

ideally permission name should .permission.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -