Hi,
Here is a simple example of how flags maybe helpful while calling back
button (btw by "back button" i mean a phone back button):
public class BodyActivity extends Activity {
OnClickListener mNextButtonListener = new OnClickListener() {
@Override
public void onClick(View v) {
restartActivity();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.body);
Button nextButton = (Button)findViewById(R.id.next_button);
nextButton.setOnClickListener(mNextButtonListener);
}
private void restartActivity() {
Intent i = new Intent(getBaseContext(), BodyActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);
}
}
if you don't use the flag in this particular example it will put the
same activity to the history stack and every time you click back
button it will go back through the stack.
If that doesn't help then pls provide more details or an example of
what you are trying to do.
On Mar 20, 5:56 am, Laxmi Verma <[email protected]> wrote:
> Hi,
>
> Thanks for your replies!!
> I am not sure how to use these flags while calling the intent. How does it
> helpful in refreshing each activity while calling back button.
>
> I am still facing this issue.
> Please help!!
>
>
>
>
>
>
>
> On Sun, Mar 20, 2011 at 1:23 AM, Nick <[email protected]> wrote:
> > Hi,
> > I'm not sure I understood your problem completely right but I guess
> > every time you send a new intent to start List Item Body Activity
> > System adds it to a history stack. Try to set intent flags like
> > FLAG_ACTIVITY_SINGLE_TOP or FLAG_ACTIVITY_NO_HISTORY
>
> > On Mar 19, 10:37 am, Laxmi Verma <[email protected]> wrote:
> > > Hi,
>
> > > Can you please provide some code example on startActivityForResult for
> > > back button refresh problem.
>
> > > Using onResume() method is not solving this problem. The reason is I am
> > > having a list item activity. From there I am calling List Item Body
> > > Activity. List Item Body Activity contains back and previous button.
> > > Now, inside List Item Body Activity if I am calling this activity itself
> > > in onResume() method then it never goes back to List
> > > Item Activity. Everytime I am pressing back button iin List Item Body
> > > Activity, it is making an intent of itself and starting it and never
> > > goes back to List Item Activity.
>
> > > Thanks!!
>
> > > On Saturday 19 March 2011 10:00 PM, Streets Of Boston wrote:
>
> > > > Yep, and if you only want to refresh when coming back from an activity
> > > > that was started by your original activity (startActivityForResult),
> > > > implement onActivityResult callback as well.
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to
> > [email protected]
> > > > To unsubscribe from this group, send email to
> > > > [email protected]
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en