ridvan
ridvan

Reputation: 743

restart Activity from other Activity

I have two Activity A and B. I want to restart B activity when goes to B activity from A activity, How can I do this?

Intent send_show = new Intent(A.this, B.class);
startActivty(send_show);

Upvotes: 1

Views: 61

Answers (2)

tiny sunlight
tiny sunlight

Reputation: 6251

You mean you only need to deal Timer?

public Timer rebuildTimer(Timer timer){
   try{
      if(timer!=null){
         timer.cancel();
         timer = new Timer();
      }
   }catch(Throwable e){

   }
   return timer;
}

private Timer mTimer;

private void onNewIntent(){
    mTimer = rebuildTimer(mTimer);
}

private void onCreate(Some params){
    mTimer = rebuildTimer(mTimer);
}

Upvotes: 0

Skizo-ozᴉʞS ツ
Skizo-ozᴉʞS ツ

Reputation: 20626

To "restart" you simply can do this :

Intent send_show = new Intent(B.this, A.class);
finish(); //here restart the B because you are on B class
startActivty(send_show);

Otherwise you can call recreate()

Edit

Since you want to "restart" the timer you could do something like this :

public void onDestroy(){
  super.onDestroy();
  //you should restart timer or just cancel and re active it in onCreate() 
}

Upvotes: 1

Related Questions