Hi~

as title , follow is the detail of my problem :

1. press home key to stop my AP (activity change to stop , not
destroy )

2. use "CountDownTimer"  for  sleep 3  secs , when timer finish  use
sendBroadcast() to call my BroadcastReceiver

3. finally , BroadcastReceiver  use intent to start my AP (activity
change to start)

follow is my code , it does not works correctly .

Thanks

code:

[Main Activity]

public class Main extends Activity {
        protected void onStop(){
                super.onStop();
                RestartCount counter = new RestartCount(5000,1000 );
                counter.start();

        }
}


public class RestartCount extends CountDownTimer {
        public RestartCount(long millisInFuture, long countDownInterval) {
                super(millisInFuture, countDownInterval);
        }

        @Override
        public void onFinish() {
                Intent it = new Intent("com.demo.TEST_COMPLETED");
                sendBroadcast(it);
        }
        @Override
        public void onTick(long millisUntilFinished) {
        }
}


[BroadcastReceiver]

public class CompleteReceiver extends BroadcastReceiver {

    public CompleteReceiver () {
    }
    @Override
    public void onReceive(Context context, Intent intent) {
                        Intent restartIntent = new Intent();
                        restartIntent.setClass(context,Main.class );
                        restartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        context.startActivity(restartIntent);
   }
}

[register BroadcastReceiver in AndroidManifast.xml]

<receiver android:name=".CompleteReceiver">
            <intent-filter>
                <action android:name="com.demo.TEST_COMPLETED" />
            </intent-filter>
</receiver>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to