last day (16 days later) » 

8:41 AM
1
A: From one activity to two other

Blaze TamaUse this for button 1 onCLick : intent.putExtra("button", "button1"); For button 2 onCLick: intent.putExtra("button", "button2"); Pass that value through from Activity 1 to Activity 3, through Activity 2. In Activity 3's onCreate, use : Bundle b = getIntent().getExtras(); if(b != null) ...

 
You mean simply to put in each activity 2 this?
 
@Goro please see my updated answer
 
I saw it and going to try this now.
One little problem. In Activity 2 I don't have button actually they are listView items.
I've edited my question. So two buttons which open same activity. And where should I use this intent.putExtra("button", "button1"); and intent.putExtra("button", "button2");
 
@Goro in your explanation, you still use intent from Act 2 to Act 3 right? You can put the code in the onListItemClick :)
 
Yes, as you can see activity 2 is same for both and then 3 must be different. Ok, so I put in this in setOnClickListener in MainActivity for each button? Then in second activity I need to get them both in same String btn = b.getExtra("button");? And in 3rd activity which will be different I will get button1 or 2 onlyString btn = b.getExtra("button");?
 
8:41 AM
"Then in second activity I need to get them both in same String btn = b.getExtra("button");" No, the value will be only one (either "button1" or "button2"). Later, you pass the value you received to the Act 3
 
Well that's what I can't understand. I have only one Activity 2. As I see it I must somehow tell to Activity 2 which button I click from MainActivity? Meaning I must tell to Activity 2 that on MainActivity I have 2 buttons and to 'watch' which one will click from here to activity 3. Or my logic is wrong? If I put only one button as get extra how will know which one is?
 
Yes, i understood your question. You pass the value from act 1 to act 2 to act 3...i will try to update my answer so u can understand easier
 
Ah, you mean I don't need to put anything in Activity 2? Also when I put in Activity 3 String btn = b.getExtra("button"); I get The method getExtra(String) is undefined for the type Bundle. I've already have there Bundle b = getIntent().getExtras();
 
You just need to pass the value you got to act 3, and sorry i updated my answer :)
 
Still open same third activity. I will update my question with what I've made.
 
8:41 AM
@Goro OK, i need to go for a while, please give your updated code :)
 
It's updated in the question.
 
@Goro See : "String button = b.getString("button1");" change to String button = b.getString("button"); (look at my answer) :)
 
Changed and same..
 
hi
and you only need one activity 3
\i need to go for a while
will chat after return :)
 
Ok, let me know when you are here and we will continue
but why one Act3 they will be different :)
but we will discus it later
 
 
9 hours later…
5:43 PM
I wont be around for 1 day.. so I will write you when I back if you have time to help me and finish this task. Thank you!
 

  last day (16 days later) »