【发布时间】:2011-12-13 04:11:17
【问题描述】:
我正在尝试在 Android 上制作动态壁纸。我有一节课
public class MyWallpaperService extends WallpaperService {
}
还有一个班级:
public class SettingsActivity extends Activity {
}
我需要让 SettingsActivity 与 MyWallpaperService 通信,以便在动态壁纸上设置值。我以前使用过aidl,并尝试将其应用于这种情况。但是,WallpaperService 似乎具有以下方法:
/**
* Implement to return the implementation of the internal accessibility
* service interface. Subclasses should not override.
*/
@Override
public final IBinder onBind(Intent intent) {
return new IWallpaperServiceWrapper(this);
}
因此,由于超类、WallpaperService 的 onBind 方法的最终声明,我无法在我的服务的 onBind 方法中返回我自己的自定义aidl 定义的绑定器。在我看来,这似乎是 Android 平台开发团队的疏忽。这是否有效地消除了任何动态壁纸中所有可能的进程间通信能力?
我在这里有什么选择?我知道我可以将 Activity 和 Service 放在同一个进程中,并让 Activity 在 Service 上设置全局变量,但这似乎很快就会变得一团糟,我想正确地做到这一点。在服务中添加广播接收器是否正确?
【问题讨论】:
标签: android android-activity android-service ipc live-wallpaper