user4417277
user4417277

Reputation:

Automatically Redirecting Activity in Android

I want to create a application where I can redirect from one activity to another activity automatically. When I come back to first activity it shall redirect 1st activity to 2nd again.

Example:

act1--->act2(automatically)--->ac3--->ect....

Now using back button, however I reached act1 then it will again automatically redirect to act2.

I used the handler's postdelay method to redirect automatically but next time when I reached back first activity it become useless.

Upvotes: 0

Views: 1497

Answers (2)

Jaswinder
Jaswinder

Reputation: 2289

Intent i = new Intent(MainActivity.this, CheckActivity.class);
 startActivityForResult(i, REQUEST_CODE_CHECK);

and get reslut In activity

  @Override 
 public void onActivityResult(int requestCode, int resultCode, Intent data)
 { 
 if (requestCode == request_Code) {
    if (resultCode == REQUEST_CODE_CHECK) 
        Toast.makeText(this,data.getData().toString(),Toast.LENGTH_SHORT).show();               
    } 
 }

Upvotes: 1

BeingMIAkashs
BeingMIAkashs

Reputation: 1385

In your automatic redirecting Activity add the onResume method in the following way

@Override
public void onResume(){
    startActivity(this, second activity intent);
}

Upvotes: 0

Related Questions