本文整理匯總了Java中android.os.Handler.dispatchMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java Handler.dispatchMessage方法的具體用法?Java Handler.dispatchMessage怎麽用?Java Handler.dispatchMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.Handler
的用法示例。
在下文中一共展示了Handler.dispatchMessage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initializeServiceKiller
import android.os.Handler; //導入方法依賴的package包/類
/**
* initialize the runnable and its Handler
*/
private void initializeServiceKiller() {
mServiceKiller = new Runnable() {
@Override
public void run() {
//one second later still no activity alive, so kill ServiceManager
mServiceKillerHandler.dispatchMessage(mServiceKillerHandler.obtainMessage());
}
};
mServiceKillerHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
Log.d("MyApplication", "in the Handler isActivityAlive==" + isActivityAlive.get());
if (isActivityAlive.get() == 0) {
//What you should do when application should die
applicationShouldDie();
}
}
};
}