Activity returns wrong requestCode









up vote
0
down vote

favorite
1












I have 4 Activities A -> B-> C -> D



from Activity D I want to go back to B



here is the code



manifest:
<activity android:name=".GetAttendance" android:launchMode="singleTask"/>


.



Activity D
Intent intent = new Intent(AddNewGuest.this, GetAttendance.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("guest", temp);// temp is an object
setResult(600, intent);
startActivity(intent);


on Activity B, I am calling:



 protected void onActivityResult(int requestCode, int resultCode, Intent data) 
super.onActivityResult(requestCode, resultCode, data);
System.out.println("requestCode:"+requestCode+" resultCode:"+resultCode);



But I am getting the requestCode equals to 1000 where it I am sending it 600



However, when Activity B calls C and before going to D I'm setting requestcode to 1000 startActivityForResult(intent, 1000);



any suggestion?










share|improve this question























  • maybe this link can help you : stackoverflow.com/questions/27225038/…
    – amir133
    Nov 9 at 19:08










  • Thanks @amir133, I tried it but its not working
    – SHADOW.NET
    Nov 9 at 19:24














up vote
0
down vote

favorite
1












I have 4 Activities A -> B-> C -> D



from Activity D I want to go back to B



here is the code



manifest:
<activity android:name=".GetAttendance" android:launchMode="singleTask"/>


.



Activity D
Intent intent = new Intent(AddNewGuest.this, GetAttendance.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("guest", temp);// temp is an object
setResult(600, intent);
startActivity(intent);


on Activity B, I am calling:



 protected void onActivityResult(int requestCode, int resultCode, Intent data) 
super.onActivityResult(requestCode, resultCode, data);
System.out.println("requestCode:"+requestCode+" resultCode:"+resultCode);



But I am getting the requestCode equals to 1000 where it I am sending it 600



However, when Activity B calls C and before going to D I'm setting requestcode to 1000 startActivityForResult(intent, 1000);



any suggestion?










share|improve this question























  • maybe this link can help you : stackoverflow.com/questions/27225038/…
    – amir133
    Nov 9 at 19:08










  • Thanks @amir133, I tried it but its not working
    – SHADOW.NET
    Nov 9 at 19:24












up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I have 4 Activities A -> B-> C -> D



from Activity D I want to go back to B



here is the code



manifest:
<activity android:name=".GetAttendance" android:launchMode="singleTask"/>


.



Activity D
Intent intent = new Intent(AddNewGuest.this, GetAttendance.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("guest", temp);// temp is an object
setResult(600, intent);
startActivity(intent);


on Activity B, I am calling:



 protected void onActivityResult(int requestCode, int resultCode, Intent data) 
super.onActivityResult(requestCode, resultCode, data);
System.out.println("requestCode:"+requestCode+" resultCode:"+resultCode);



But I am getting the requestCode equals to 1000 where it I am sending it 600



However, when Activity B calls C and before going to D I'm setting requestcode to 1000 startActivityForResult(intent, 1000);



any suggestion?










share|improve this question















I have 4 Activities A -> B-> C -> D



from Activity D I want to go back to B



here is the code



manifest:
<activity android:name=".GetAttendance" android:launchMode="singleTask"/>


.



Activity D
Intent intent = new Intent(AddNewGuest.this, GetAttendance.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("guest", temp);// temp is an object
setResult(600, intent);
startActivity(intent);


on Activity B, I am calling:



 protected void onActivityResult(int requestCode, int resultCode, Intent data) 
super.onActivityResult(requestCode, resultCode, data);
System.out.println("requestCode:"+requestCode+" resultCode:"+resultCode);



But I am getting the requestCode equals to 1000 where it I am sending it 600



However, when Activity B calls C and before going to D I'm setting requestcode to 1000 startActivityForResult(intent, 1000);



any suggestion?







java android android-intent android-activity






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 19:56

























asked Nov 9 at 18:49









SHADOW.NET

921110




921110











  • maybe this link can help you : stackoverflow.com/questions/27225038/…
    – amir133
    Nov 9 at 19:08










  • Thanks @amir133, I tried it but its not working
    – SHADOW.NET
    Nov 9 at 19:24
















  • maybe this link can help you : stackoverflow.com/questions/27225038/…
    – amir133
    Nov 9 at 19:08










  • Thanks @amir133, I tried it but its not working
    – SHADOW.NET
    Nov 9 at 19:24















maybe this link can help you : stackoverflow.com/questions/27225038/…
– amir133
Nov 9 at 19:08




maybe this link can help you : stackoverflow.com/questions/27225038/…
– amir133
Nov 9 at 19:08












Thanks @amir133, I tried it but its not working
– SHADOW.NET
Nov 9 at 19:24




Thanks @amir133, I tried it but its not working
– SHADOW.NET
Nov 9 at 19:24












1 Answer
1






active

oldest

votes

















up vote
0
down vote













You are sending a requestCode of 1000, which can be seen from your startActivityForResult(intent, 1000); statement



You were expecting a 600, but the call to setResult(600, intent); is setting the result code to 600



This is different because you are expecting for a request code, whereas the 600 value is for result code



https://developer.android.com/reference/android/app/Activity#setResult(int,%20android.content.Intent)






share|improve this answer




















  • OK, the resultCode returns as 0
    – SHADOW.NET
    Nov 9 at 20:26










  • A result code of 0 means cancelled, or you pressed back button or you did not set a a resultvalue. developer.android.com/reference/android/app/…
    – JoM
    Nov 9 at 20:28











  • Even when I return back from C to B I get reultCode=0
    – SHADOW.NET
    Nov 9 at 20:28










  • call setResult() , then call finish() not startactivity. Finish() will trigger the onActivityResult() callback of the previous screen
    – JoM
    Nov 9 at 20:33











  • I am calling setResult(600, intent). and using startActivity() because finish() will return to the previous one C while I need to go to B
    – SHADOW.NET
    Nov 9 at 20:36











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231696%2factivity-returns-wrong-requestcode%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You are sending a requestCode of 1000, which can be seen from your startActivityForResult(intent, 1000); statement



You were expecting a 600, but the call to setResult(600, intent); is setting the result code to 600



This is different because you are expecting for a request code, whereas the 600 value is for result code



https://developer.android.com/reference/android/app/Activity#setResult(int,%20android.content.Intent)






share|improve this answer




















  • OK, the resultCode returns as 0
    – SHADOW.NET
    Nov 9 at 20:26










  • A result code of 0 means cancelled, or you pressed back button or you did not set a a resultvalue. developer.android.com/reference/android/app/…
    – JoM
    Nov 9 at 20:28











  • Even when I return back from C to B I get reultCode=0
    – SHADOW.NET
    Nov 9 at 20:28










  • call setResult() , then call finish() not startactivity. Finish() will trigger the onActivityResult() callback of the previous screen
    – JoM
    Nov 9 at 20:33











  • I am calling setResult(600, intent). and using startActivity() because finish() will return to the previous one C while I need to go to B
    – SHADOW.NET
    Nov 9 at 20:36















up vote
0
down vote













You are sending a requestCode of 1000, which can be seen from your startActivityForResult(intent, 1000); statement



You were expecting a 600, but the call to setResult(600, intent); is setting the result code to 600



This is different because you are expecting for a request code, whereas the 600 value is for result code



https://developer.android.com/reference/android/app/Activity#setResult(int,%20android.content.Intent)






share|improve this answer




















  • OK, the resultCode returns as 0
    – SHADOW.NET
    Nov 9 at 20:26










  • A result code of 0 means cancelled, or you pressed back button or you did not set a a resultvalue. developer.android.com/reference/android/app/…
    – JoM
    Nov 9 at 20:28











  • Even when I return back from C to B I get reultCode=0
    – SHADOW.NET
    Nov 9 at 20:28










  • call setResult() , then call finish() not startactivity. Finish() will trigger the onActivityResult() callback of the previous screen
    – JoM
    Nov 9 at 20:33











  • I am calling setResult(600, intent). and using startActivity() because finish() will return to the previous one C while I need to go to B
    – SHADOW.NET
    Nov 9 at 20:36













up vote
0
down vote










up vote
0
down vote









You are sending a requestCode of 1000, which can be seen from your startActivityForResult(intent, 1000); statement



You were expecting a 600, but the call to setResult(600, intent); is setting the result code to 600



This is different because you are expecting for a request code, whereas the 600 value is for result code



https://developer.android.com/reference/android/app/Activity#setResult(int,%20android.content.Intent)






share|improve this answer












You are sending a requestCode of 1000, which can be seen from your startActivityForResult(intent, 1000); statement



You were expecting a 600, but the call to setResult(600, intent); is setting the result code to 600



This is different because you are expecting for a request code, whereas the 600 value is for result code



https://developer.android.com/reference/android/app/Activity#setResult(int,%20android.content.Intent)







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 9 at 20:18









JoM

12415




12415











  • OK, the resultCode returns as 0
    – SHADOW.NET
    Nov 9 at 20:26










  • A result code of 0 means cancelled, or you pressed back button or you did not set a a resultvalue. developer.android.com/reference/android/app/…
    – JoM
    Nov 9 at 20:28











  • Even when I return back from C to B I get reultCode=0
    – SHADOW.NET
    Nov 9 at 20:28










  • call setResult() , then call finish() not startactivity. Finish() will trigger the onActivityResult() callback of the previous screen
    – JoM
    Nov 9 at 20:33











  • I am calling setResult(600, intent). and using startActivity() because finish() will return to the previous one C while I need to go to B
    – SHADOW.NET
    Nov 9 at 20:36

















  • OK, the resultCode returns as 0
    – SHADOW.NET
    Nov 9 at 20:26










  • A result code of 0 means cancelled, or you pressed back button or you did not set a a resultvalue. developer.android.com/reference/android/app/…
    – JoM
    Nov 9 at 20:28











  • Even when I return back from C to B I get reultCode=0
    – SHADOW.NET
    Nov 9 at 20:28










  • call setResult() , then call finish() not startactivity. Finish() will trigger the onActivityResult() callback of the previous screen
    – JoM
    Nov 9 at 20:33











  • I am calling setResult(600, intent). and using startActivity() because finish() will return to the previous one C while I need to go to B
    – SHADOW.NET
    Nov 9 at 20:36
















OK, the resultCode returns as 0
– SHADOW.NET
Nov 9 at 20:26




OK, the resultCode returns as 0
– SHADOW.NET
Nov 9 at 20:26












A result code of 0 means cancelled, or you pressed back button or you did not set a a resultvalue. developer.android.com/reference/android/app/…
– JoM
Nov 9 at 20:28





A result code of 0 means cancelled, or you pressed back button or you did not set a a resultvalue. developer.android.com/reference/android/app/…
– JoM
Nov 9 at 20:28













Even when I return back from C to B I get reultCode=0
– SHADOW.NET
Nov 9 at 20:28




Even when I return back from C to B I get reultCode=0
– SHADOW.NET
Nov 9 at 20:28












call setResult() , then call finish() not startactivity. Finish() will trigger the onActivityResult() callback of the previous screen
– JoM
Nov 9 at 20:33





call setResult() , then call finish() not startactivity. Finish() will trigger the onActivityResult() callback of the previous screen
– JoM
Nov 9 at 20:33













I am calling setResult(600, intent). and using startActivity() because finish() will return to the previous one C while I need to go to B
– SHADOW.NET
Nov 9 at 20:36





I am calling setResult(600, intent). and using startActivity() because finish() will return to the previous one C while I need to go to B
– SHADOW.NET
Nov 9 at 20:36


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231696%2factivity-returns-wrong-requestcode%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo