Linking.sendIntent startActivity from outside of an Activity context error
See original GitHub issueDescription
I am trying to open security settings on android using Linking module :
Linking.sendIntent("android.settings.SECURITY_SETTINGS");
This result to this red box error:
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
React Native version:
React Native : 0.61.5
System: OS: macOS 10.15.4 CPU: (4) x64 Intel® Core™ i7-7660U CPU @ 2.50GHz Memory: 26.83 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2 IDEs: Android Studio: 3.6 AI-192.7142.36.36.6392135 Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
Steps To Reproduce
- Call
Linking.sendIntent("android.settings.SECURITY_SETTINGS");
in Android (9 in my test)
Expected Results
Security settings should open without error.
Suggestion
Add FLAG_ACTIVITY_NEW_TASK
flag by default on indent or add ability on sendIntent
to add flags.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:6 (2 by maintainers)
Any update on this issue? I just ran into the same when linking to android’s WiFi settings:
Looks like it was merged https://github.com/facebook/react-native/pull/29000? In what release will it go out in?
Going to work on that. I’m going to the same thing as it’s in
openURL
:https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java#L97-L101