0

Here's My Running Activity Stack Now I Want to choose A specific Activity from the multiple running Instance of same activity Like I have a activity displaymessage Which I am creating according to this logic

list.setOnItemClickListener(new OnItemClickListener(){

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position,
                long id) {


            String temp = userlist.get(position).getId();
            int flag = 1;
            Intent i = new Intent();

             for (String s : recent_id){
                if (s.equals(temp)){
                    flag = 0 ;
                    break;
                }

             }
             if(flag == 1)
                recent_id.add(userlist.get(position).getId());

             else if(flag == 0)
               i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);


             i.setClass(DisplayUser.this, MessageActivity.class);
             i.putExtra("position", String.valueOf(position + 1));
             i.putExtra("icon", userlist.get(position).getIcon());
             i.putExtra("name", userlist.get(position).getName());
             startActivity(i);

        }


    });

I want to attach some id to my displaymessage activity so whenever it's new instance is launched a id is attached to it and i can retrieve from activity stack easily .. can i do it that way or I am completely wrong ?

Rohit
  • 179
  • 3
  • 14

1 Answers1

0

First of all you need to understand what activity life cycle is.

According to your requirement try this link this might help you.

You can call which activity you want according specific result you had mentioned to your activity using startActivityForResult() method.

Community
  • 1
  • 1
Gru
  • 2,686
  • 21
  • 29