New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mark cocos2dx activity as "singleTask" on android #19010

Merged
merged 1 commit into from Sep 4, 2018

Conversation

Projects
None yet
3 participants
@drelaptop
Collaborator

drelaptop commented Sep 4, 2018

this PR prevent the side effect from #18247

the issue is game will exit with exception, when cocos2dx activity isn't the first Activity

How to reproduce

  1. add a start activity for cocos2dx game
  2. jump to cocos2dx activity by Intent
  3. cocos2dx activity finished directly, because !isTaskRoot() is triggered
@crazyhappygame

This comment has been minimized.

Show comment
Hide comment
@crazyhappygame

crazyhappygame Sep 4, 2018

Contributor

Do we still need below code after this PR:
protected void onCreate(Bundle savedInstanceState) {
super.setEnableVirtualButton(false);
super.onCreate(savedInstanceState);
// Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508
if (!isTaskRoot()) {
// Android launched another instance of the root activity into an existing task
// so just quietly finish and go away, dropping the user back into the activity
// at the top of the stack (ie: the last state of this task)
// Don't need to finish it again since it's finished in super.onCreate .
return;
}
// DO OTHER INITIALIZATION BELOW

}
Contributor

crazyhappygame commented Sep 4, 2018

Do we still need below code after this PR:
protected void onCreate(Bundle savedInstanceState) {
super.setEnableVirtualButton(false);
super.onCreate(savedInstanceState);
// Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508
if (!isTaskRoot()) {
// Android launched another instance of the root activity into an existing task
// so just quietly finish and go away, dropping the user back into the activity
// at the top of the stack (ie: the last state of this task)
// Don't need to finish it again since it's finished in super.onCreate .
return;
}
// DO OTHER INITIALIZATION BELOW

}
@minggo

This comment has been minimized.

Show comment
Hide comment
@minggo

minggo Sep 4, 2018

Contributor

@crazyhappygame yep, it is needed, they resolve different issues.

Contributor

minggo commented Sep 4, 2018

@crazyhappygame yep, it is needed, they resolve different issues.

@minggo minggo added this to the 3.18 milestone Sep 4, 2018

@minggo minggo merged commit 80279cb into cocos2d:v3 Sep 4, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@drelaptop

This comment has been minimized.

Show comment
Hide comment
@drelaptop

drelaptop Sep 4, 2018

Collaborator

from the NDK issue tracker, I known the android issue (#18247 fixed) still occurs on 2017, even 2018.

refer to https://issuetracker.google.com/issues/36907463

vs...@gmail.com  <vs...@gmail.com>  #54 Dec 28, 2017 03:25PM 
Good Afternoon,

My issues is
1.When i open and and went to some activity.
2.then i click home button,then it go to background task.
3.when it click lauch icon .app is not resumed activity. it starts from Splash activity.
This is only occurs in released App not debug app.debug app working well,

I tried launchmode="singleInstance" or "SingleTop" what else..i tired all posibilities..other than any reply to me.
Regards,
Srinivas

in...@bigredzebra.com  <in...@bigredzebra.com>  #57 Jun 1, 2018 11:32PM 
I already opened a new issue for this problem (which has still not been resolved, but is still open) here: https://issuetracker.google.com/issues/64108432

So, when the cocos2dx activity is the second activity, the issue maybe occur on the start activity, then the hack code block should be move to start activity that developer custom.

Collaborator

drelaptop commented Sep 4, 2018

from the NDK issue tracker, I known the android issue (#18247 fixed) still occurs on 2017, even 2018.

refer to https://issuetracker.google.com/issues/36907463

vs...@gmail.com  <vs...@gmail.com>  #54 Dec 28, 2017 03:25PM 
Good Afternoon,

My issues is
1.When i open and and went to some activity.
2.then i click home button,then it go to background task.
3.when it click lauch icon .app is not resumed activity. it starts from Splash activity.
This is only occurs in released App not debug app.debug app working well,

I tried launchmode="singleInstance" or "SingleTop" what else..i tired all posibilities..other than any reply to me.
Regards,
Srinivas

in...@bigredzebra.com  <in...@bigredzebra.com>  #57 Jun 1, 2018 11:32PM 
I already opened a new issue for this problem (which has still not been resolved, but is still open) here: https://issuetracker.google.com/issues/64108432

So, when the cocos2dx activity is the second activity, the issue maybe occur on the start activity, then the hack code block should be move to start activity that developer custom.

@drelaptop

This comment has been minimized.

Show comment
Hide comment
@drelaptop

drelaptop Sep 4, 2018

Collaborator

I think the main reason is android:launchMode isn't always works, for some other developers tried, and failed. so keep the hack code block is more stable. @crazyhappygame

Collaborator

drelaptop commented Sep 4, 2018

I think the main reason is android:launchMode isn't always works, for some other developers tried, and failed. so keep the hack code block is more stable. @crazyhappygame

@crazyhappygame

This comment has been minimized.

Show comment
Hide comment
@crazyhappygame

crazyhappygame Sep 5, 2018

Contributor

Thanks for explaining

Contributor

crazyhappygame commented Sep 5, 2018

Thanks for explaining

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment