Reputation: 71
I build a simple remote service with aidl file. The service and the activity are in two diferent virtual device. The service isn't reachable with an activity. I think the service doesn't start. In DDMS view my service doen't appear and LogCat launch an error : unable to start service Intent { cmp = com.michelService.BIND pkg=com.michelService}: not found
THANKS for your help!
My AndroidManifest.xml :
*<?xml *version*="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.michelService"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="13" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<service android:name=".ServiceHello" android:exported="true" >
<intent-filter>
<action android:name="com.michelService.BIND"></action>
</intent-filter>
</service>
</application>
</manifest>*
My activity : CallServiceActivity.java :
public class CallServiceActivity extends Activity {
/** Called when the activity is first created. */
IServiceHello service;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout layout = new LinearLayout(this);
TextView tv1 = new TextView(this);
Intent intent = new Intent();
intent.setAction("com.michelService.BIND");
intent.setPackage("com.michelService");
startService(intent);
ServiceConnection con = new ServiceConnection(){
@Override
public void onServiceConnected(ComponentName arg0, IBinder binder) {
service = IServiceHello.Stub.asInterface(binder);
}
@Override
public void onServiceDisconnected(ComponentName arg0) {
service= null;
}
};
bindService(intent, con, Context.BIND_AUTO_CREATE);
try {
tv1.setText(service.sayHello("Michel"));
} catch (RemoteException e) {
// TODO Auto-generated catch block
tv1.setText("" + e);
}
layout.addView(tv1);
setContentView(layout);
}
}
Upvotes: 0
Views: 1833
Reputation: 63955
The service and the activity are in two diferent virtual device.
It does not work then. You can use services only on the same device. If you want to communicate with a different device then you have to do that via network.
You probably want to start both on the same.
Remote service means "in a different Process" here. You use AIDL to access the other process. Different Processes are a bit like different devices since they don't share a common environment and the communication between them is also a bit like network communication.
Upvotes: 1