Skip to content
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

Calling startActivity() #1

Closed
TechNerdsUzi opened this issue Aug 3, 2018 · 3 comments
Closed

Calling startActivity() #1

TechNerdsUzi opened this issue Aug 3, 2018 · 3 comments

Comments

@TechNerdsUzi
Copy link

i have an error while lunch google maps
Error: Calling startActivity() from outside of an activity context requires the FLAG_ACTIVITY_NEW_TASK flag. is this really what you want ?

can you tell me how to fix this ?

@dpa99c
Copy link
Owner

dpa99c commented Aug 4, 2018

I haven't encountered this problem in the example test project - have you tried building and running it?

And are you by any chance using react-native-navigation in your project? Since React Native is mono-activity by default, react-native-navigation is the most common way that multiple activities are introduced into React Native apps.

This SO answer indicates the quickest fix would be to set the FLAG_ACTIVITY_NEW_TASK flag on the intent, but I fear this would interfere with the history stack of react-native-navigation.

Currently this module uses the getReactApplicationContext() method of the ReactContextBaseJavaModule parent class to pass as context to the LaunchNavigator class for use in launch intents.

However, I will investigate if it's possible to obtain a reference to the current activity via the parent class, as I think passing the Activity context instead of the Application context would resolve this issue.

@dpa99c
Copy link
Owner

dpa99c commented Aug 4, 2018

On further investigation, it's OK to use the FLAG_ACTIVITY_NEW_TASK flag because the intent launches another application so won't interfere with the history stack of the calling application. Therefore I'll commit a change to add this flag and publish a patch release.

@dpa99c dpa99c closed this as completed in cda7e83 Aug 4, 2018
@dpa99c
Copy link
Owner

dpa99c commented Aug 4, 2018

The above commit is published in v1.0.1
Please let me know if that doesn't resolve your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants