created four activity, i want to go last activity to second activity through back button pressed.
---------------------------------------------------------------------------------------------
Main_activity.java
Second.java
Third.java
Last.java
------------
public class Last extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.last);
}
@SuppressLint("InlinedApi")
@Override
public void onBackPressed()
{
super.onBackPressed();
Intent intent = new Intent(getApplicationContext(), Second.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
}
---------------------------------------------------------------------------------------------
Main_activity.java
Second.java
Third.java
Last.java
------------
public class Last extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.last);
}
@SuppressLint("InlinedApi")
@Override
public void onBackPressed()
{
super.onBackPressed();
Intent intent = new Intent(getApplicationContext(), Second.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
}