Activity returns wrong requestCode
up vote
0
down vote
favorite
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
add a comment |
up vote
0
down vote
favorite
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
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
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
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
java android android-intent android-activity
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
add a comment |
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
add a comment |
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)
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 oneC
while I need to go toB
– SHADOW.NET
Nov 9 at 20:36
|
show 3 more comments
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)
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 oneC
while I need to go toB
– SHADOW.NET
Nov 9 at 20:36
|
show 3 more comments
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)
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 oneC
while I need to go toB
– SHADOW.NET
Nov 9 at 20:36
|
show 3 more comments
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)
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)
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 oneC
while I need to go toB
– SHADOW.NET
Nov 9 at 20:36
|
show 3 more comments
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 oneC
while I need to go toB
– 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
|
show 3 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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