Reputation: 33
when I am firing an activity through intent the activity instances is created multiple times (3) in the stack and this makes me click back button thrice to come to previous activity. Im not able to figure out what is the reason behind this kindly help me. this is the code snippet,
Intent mIntent = new Intent(MainActivity.this, B.class);
startActivityForResult(mIntent, Constants.B_Issue);
EDIT : Im using this in onPageScrolled
@Override
public void onPageScrolled(final int position, float positionOffset, int positionOffsetPixels) {
Log.e(TAG, " On Page Scrolled invoked ");
posOffset = positionOffset;
if (lastState == ViewPager.SCROLL_STATE_DRAGGING) {
Intent mIntent = new Intent(MainActivity.this, Test.class);
startActivityForResult(mIntent, Constants.TEST_WORK);
}
}
Upvotes: 0
Views: 100
Reputation: 531
Where have u called below code?
Intent mIntent = new Intent(MainActivity.this, B.class);
startActivityForResult(mIntent, Constants.B_Issue);
I think this code is called multiple times, which is creating multiple instances of activity. I can help you more, if you can provide complete MainActivity.
Upvotes: 1
Reputation: 61
Use this
Intent mIntent = new Intent(MainActivity.this, B.class);
startActivity(mIntent);
Instead of this
Intent mIntent = new Intent(MainActivity.this, B.class);
startActivityForResult(mIntent, Constants.B_Issue);
Upvotes: 0
Reputation: 3422
Try below code for going one activity to other;
Intent mIntent = new Intent(MainActivity.this, B.class);
startActivity(mIntent);
Upvotes: 0