我想在Android上製作動態壁紙。我有一類IPC與WallpaperService的子類
public class MyWallpaperService extends WallpaperService {
}
而且annother類:
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);
}
所以我可以在我自己的自定義AIDL在我服務的onBind方法定義粘結劑不會返回由於對超類,WallpaperService的,onBind方法的最後宣言。對我來說,這似乎是Android平臺開發團隊的疏忽。這是否有效地消除了來自任何動態壁紙的所有可能的進程間通信能力?
我在這裏有什麼選擇?我知道我可以將Activity和Service放在同一個進程中,並讓Activity在Service上設置全局變量,但看起來它可能會變得很亂,我想正確地做到這一點。在服務中添加廣播接收器是否正確?