Hi All,

Thanks for your replies:

*Problem Detail*:
I am having an activity containing next and previous button.  On clicking
next and previous button I am calling the same activity itself but with
different content.
Now, If I am calling this activity by startActivity() in onResume() method,
the problem what coming is that if I click on back button (Phone) it goes to
the onResume method of this activity and calling this activity again.  So,
everytime I am pressing back button, it is calling the same activity itself
and never goes back to the home screen.
The same problem is occurring with on key back method.

I am not sure how to do this.  I tried various Intent flags also but of no
use for e.g. FLAG_ACTIVITY_CLEAR_TOP, FLAG_ACTIVITY_SINGLE_TOP and
FLAG_ACTIVITY_NO_HISTORY

Any help in this regard would be highly appreciated as I need this on urgent
basis.

Thanks!!



On Tue, Mar 22, 2011 at 9:39 PM, Laxmi Verma
<laxmiverma.andr...@gmail.com>wrote:

> Hi,
>
> Thanks for giving the reply.  But it does not resolve the problem.
>
> 1) *Problem Detail*
>
> I am having a list view item activity having a list of items to be viewed.
> After clicking on the item it goes to the Item Body Activity having the
> detailed description of the list item.  Inside Item Body Activity, I am
> having 2 buttons : previous and next.
> Now, my problem is if I go to first list body activity and then click on
> next button from there i.e. navigating to 2 list body items, and after that
> pressing back button it should refresh my previous item body activity.
>
>
> a) *Intent.FLAG_ACTIVITY_SINGLE_TOP* using this does not resolve the
> problem as it always go back to the list item activity while pressing back
> button does not matters how much item body activity i navigated.
>
> b) *Intent.FLAG_ACTIVITY_CLEAR_TOP *is also not resolving the problem as
> it always show the first item body activity no matter how much i navigate
> from there after clicking next button and does not refresh on back button.
>
>
> Any help in this regard is highly appreciated as I required this thing on
> urgent basis.
>
>
>
>
>
> While setting flag FLAG_ACTIVITY_SINGLE_TOP and pressing back button, no
> matter how muc
>
>
> On Mon, Mar 21, 2011 at 1:45 AM, Nick <nkulik...@gmail.com> wrote:
>
>> 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 <laxmiverma.andr...@gmail.com> 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 <nkulik...@gmail.com> 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 <laxmiverma.andr...@gmail.com>
>> 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
>> > > android-developers@googlegroups.com
>> > > > > To unsubscribe from this group, send email to
>> > > > > android-developers+unsubscr...@googlegroups.com
>> > > > > 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
>> android-developers@googlegroups.com
>> > > To unsubscribe from this group, send email to
>> > > android-developers+unsubscr...@googlegroups.com
>> > > 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 android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to