以前のセッション (onPause、onDestroy() の前) で以前に作成されたアクティビティの次のライフで Handler オブジェクトを再利用しても問題ありませんか?
アクティビティでハンドラを作成して他のオブジェクトに伝播するように、アクティビティは死ぬか一時停止し、その後再び生き返って古いハンドラを使用しますか?
// In the oncreate() method I have this code to recreate handler every time
// Then I set the handler to a static Global object
// Other Objects use the global object's static method to get
//fresh handler every timebefore calling sendMessage()
/**
* Set up handler
*/
Handler h = new Handler(new Callback()
{
public boolean handleMessage(Message msg)
{
handleServiceMessage(msg);
return true;
}
});
uiglobal = new UIGlobals(h);
UiGlobals は次のように宣言されています
private static UIGlobals uiglobal = null;
上記のアプローチが正しいかどうかわからない..
私のGlobalUIクラスは次のようになります
public class UIGlobals
{
private static Handler handler = null;
public UIGlobals(Handler h)
{
handler = h;
}
public static Handler getHandler()
{
return handler;
}
}