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
-~----------~----~----~----~------~----~------~--~---