I'm trying to remote control a live wallpaper from a widget. They're in the same APK, but obviously different processes. Calling an "activity" of the live wallpaper is of little use to me since it is a different process. The widget has simple buttons that, when pressed,
So what (I think) I need is IPC and AIDL.
First I created the AIDL on the wallpaper side, which worked fine. It has three methods with no extra parameters. But when I added the clientside to the widget, I got an error telling me that I cannot bind to that remote interface because the widget is already a BroadcastListener. I tried getting button handling in without needing the Widget to be a BroadcastListener, but that seems to be impossible.
Well no problem, right? I just created a service within the widget that binds to the remote interface, because while the widget is a BroadcastListener, the service is not, and everything should be fine.
Or so I thought.
Well, I'm getting the widget's buttons to trigger the widget service. Binding to the remote service yields me the following warning:
Unable to start service Intent (act=com.blabla.IRemoteService): not found.
I am using getApplicationContext() within the service of the widget to bind to the remote stuff. I do have the widget service in the manifest, but I don't have the remote service in there. When I do put it in there, I get a nonspecific InstantiationException.
In the Widget's Service onStart() I am doing this:
getApplicationContext().bindService(new Intent(IWallpaperRemote.class.getName()),
mConnection, Context.BIND_AUTO_CREATE);
I also have...
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className,
IBinder service) {
mService = IWallpaperRemote.Stub.asInterface(service);
isBound = true;
Log.i("WidgetServiceConnection", "binding to service succeeded");
}
public void onServiceDisconnected(ComponentName className) {
mService = null;
isBound = false;
Log.i("WidgetServiceConnection", "binding to service lost!");
}
};
My question is this: Has anyone ever successfully done a remote call from a widget into another application? Considering I am talking about a live wallpaper here, and the fact that I'm not interested in calling an activity within the widget process but cause function calls within the live wallpaper, what options do I have other than IPC, if any?
And if IPC is the way to go here, what am I doing wrong?