Thanks a lot for analyzing the problem.

First, my comment on your second point -
This I had already been doing - as in the client application's
manifest, the service application's manifest too has this entry under
the manifest tag:
<uses-permission
android:name="android.permission.ACCESS_BACKGROUND_SERVICE" />


Now coming to the first point, I changed the client code line from -
Intent intent = new Intent(this,
com.abc.xyz.service.BackgroundService.class);
to
Intent intent = new Intent("com.abc.xyz.service.BackgroundService");

After the change, it seems the service is identified and the earlier
warning message -
"Unable to start service Intent{ comp={com.abc.xyz.client/
com.abc.xyz.service.BackgroundService} }:not found "
is not coming.
But then the permission related SecurityException is coming at the
client statement "startService(intent)" as below:

- WARN/PackageManager(57): Not granting permission
android.permission.ACCESS_BACKGROUND_SERVICE to package
com.abc.xyz.client (protectionLevel=3 flags=0x44)
- ERROR/AndroidRuntime(1111): ERROR: thread attach failed
- WARN/ActivityManager(57): Permission Denial: Accessing service
ComponentInfo{com.abc.xyz/com.abc.xyz.service.BackgroundService} from
pid=57, uid=1000 requires android.permission.ACCESS_BACKGROUND_SERVICE
- ERROR/AndroidRuntime(1120): java.lang.RuntimeException: Unable to
start activity ComponentInfo{com.abc.xyz.client/
com.abc.xyz.client.ClientActivity}: java.lang.SecurityException: Not
allowed to start service Intent
{ action=com.abc.xyz.service.BackgroundService } without permission
android.permission.ACCESS_BACKGROUND_SERVICE


I think I am missing something with the declaration of permission in
the manifest(s). What is your opinion?

Thanks,
Raktim.


On Nov 11, 4:48 am, hackbod <[EMAIL PROTECTED]> wrote:
> The Intent you are making to bind to the service is trying to find a
> component in your own .apk, not the other.
>
> The last permission error you mention is because you need to
> explicitly request to use even your own permissions.
>
> On Nov 10, 9:31 pm, Raktim Das <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> > I am using 0.9 beta SDK.
> > I want to have a service defined within one application to be
> > invokable from another.
> > The application hosting the service has, in its manifest, the
> > following inside the application tag:
>
> > <service android:name=".service.BackgroundService"
> > android:process=":remote"  android:exported="true"
> > android:permission="android.permission.ACCESS_BACKGROUND_SERVICE">
> >         <intent-filter>
> >                 <action 
> > android:name="com.abc.xyz.service.BackgroundService" />
> >         </intent-filter>
> > </service>
>
> > It also has the following inside the manifest tag:
> > <permission android:name="android.permission.BACKGROUND_SERVICE"
> > android:protectionLevel="dangerous"/>
>
> > In my client application's manifest xml file, I have the following
> > inside manifest tag:
> > <uses-permission
> > android:name="android.permission.ACCESS_BACKGROUND_SERVICE" />
>
> > The client Activity code has the following API called from its
> > onCreate() method:
>
> >     private void startBackgroundService()
> >     {
> >         mConnection = new ServiceConnection()
> >         {
> >             public void onServiceConnected(ComponentName className,
> > IBinder service)
> >             {
> >                 Log.i(TAG, "Connected to background service");
> >                 mService =
> > BackgroundService.Stub.asInterface(service);
> >             }
>
> >             public void onServiceDisconnected(ComponentName className)
> >             {
> >                 mService = null;
> >                 Log.i(TAG, "Background service disconnected");
> >             }
> >         };
>
> >         Intent intent = new Intent(this,
> >                 com.abc.xyz.service.BackgroundService.class);
>
> >         startService(intent);
>
> >         boolean result = bindService(intent, mConnection,
> > Context.BIND_AUTO_CREATE);
>
> >         Log.i(TAG, "Background service bind result:  " + result);
> >     }
>
> > When I run the client Activity, it can not bind to the service:
> > - the log statement at the end has "Background service bind result:
> > false".
> > - the onServiceConnected() method is not called
> > - There is a waring log from ActivityManager:
> > WARN/ActivityManager(58): Unable to start service Intent
> > { comp={com.abc.xyz.client/com.abc.xyz.service.BackgroundService} }:
> > not found
>
> > I have tried running the same without any permission in the service
> > application manifest and also without the uses-permission tag in
> > client. The result was the same.
>
> > But when I run a similar client code inside my service application
> > (without specifying any permissions), it runs perfectly.
>
> > Finally, the most peculiar thing is happening when I am running this
> > client code inside my service application but with the permissions
> > specified (as written above) in the manifest - it runs with this error
> > at the statement "startService(intent)":
>
> > Caused by: java.lang.SecurityException: Not allowed to start service
> > Intent { comp={com.abc.xyz/com.abc.xyz.service.BackgroundService} }
> > without permission android.permission.ACCESS_BACKGROUND_SERVICE
>
> > Any hint on this will be highly appreciated. I'd also like to know
> > whether I can start and access the service from an ActivityGroup
> > outside the service application domain.
>
> > Thanks,
> > -Raktim.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to