How can i make an intent on the same Activity?
I have a Activity Lektion which has forward and backwards buttons, and when i hit on the forward button i want to start the same Activity just with other parameters.
For that i also send a bundle with the Intent.
But the Activity isnt going to be created again as it seems…
public class Lektion extends Activity {
private int rowCount = 0;
private ArrayList<LektionPage> lektionPages = new ArrayList<LektionPage>();
private int lektionPage = 0;
private Bundle bundle;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lektion);
bundle = this.getIntent().getExtras();
String lektionNummer = bundle.getString("LektionNummer");
setTitle("Lektion "+lektionNummer);
try{
lektionPage = bundle.getInt("LektionPage");
} catch(Exception e){}
forwardImageButton.setOnTouchListener(new OnTouchListener(){
public boolean onTouch(View view, MotionEvent me) {
if(lektionPage == rowCount){
return false;
}
Log.i("ontouch", ""+lektionPage);
Intent intent = new Intent(Lektion.this, Lektion.class);
bundle.putInt("LektionPage", lektionPage++);
intent.putExtras(bundle);
return true;
}
});
}
You are only creating the intent without ever firing it.
You need to
for the Intent to actually be executed.
But id say you should only change the content of the activities view etc instead of creating the activity over and over again