Java Code Examples for android.os.Handler.dispatchMessage()

The following are Jave code examples for showing how to use dispatchMessage() of the android.os.Handler class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: MultiplicationBasile   File: MyApplication.java   View Source Code Vote up 6 votes
/**
 * 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();
            }
        }
    };
}