Skip to content Skip to sidebar Skip to footer

Using Intents To Start Over The Activity

Intent i= new Intent( SetTest.this, SetTest.this);// compile error there i.putExtra('question_number', questionNumber++); startActivity(i); I want to post the data to the same act

Solution 1:

AS the other answers say :

Intent i= new Intent( SetTest.this, SetTest.Class);
i.putExtra("question_number", questionNumber++);
startActivity(i);
finish();

As you're loading the same activity, you might want finish your current activity to avoid problem in your navigation tree


Solution 2:

Save off the context of the activity to a member varaible, and then use the saved context in your intent creation.

private Context _context;

Constructor...
{
_context = this;
}

Then in the button callback:

Intent i= new Intent( _context, newDesiredClass.class);

Solution 3:

use this

Intent i= new Intent( SetTest.this, SetTest.Class);

Hope this will work


Post a Comment for "Using Intents To Start Over The Activity"