Wednesday, 28 August 2013

Start new Activity with button with FLAG_ACTIVITY_SINGLE_TOP on Android

Start new Activity with button with FLAG_ACTIVITY_SINGLE_TOP on Android

Basically Im trying start new Activity with button. Problem is in
MainActivity class Im using:
mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this,
getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
I think thats reason why when Im trying start new activity I still can see
only MainActivity because its still on the TOP of screen. I tried use
this:
public void handleClick(View v){
//Create an intent to start the new activity.
Intent intent = new Intent();
intent.setClass(this,Page2Activity.class);
startActivity(intent);
}
but still can't see new activity opened. Is it way how I can start new
Activity on the top of screen? Thank you.

No comments:

Post a Comment