question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linking.sendIntent startActivity from outside of an Activity context error

See original GitHub issue

Description

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

  1. 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:open
  • Created 3 years ago
  • Reactions:13
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
acrabbcommented, Dec 15, 2021

Any update on this issue? I just ran into the same when linking to android’s WiFi settings:

Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

Looks like it was merged https://github.com/facebook/react-native/pull/29000? In what release will it go out in?

1reaction
krizzucommented, May 28, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Calling startActivity() from outside of an Activity context
The problem is with context. If you want to open any links (for example share any link through chooser) pass activity context, not...
Read more >
Solving Calling startActivity() from outside of an Activity context ...
This video shows you how to solve the Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag ...
Read more >
Sending simple data to other apps - Android Developers
The Android Sharesheet is primarily designed for sending content outside your app and/or directly to another user. For example, sharing a URL with...
Read more >
How to set flag when sending android intent? : r/reactnative
sendIntent (action, extras);. And I get this error. Calling startActivity() from outside of an Activity context requires the ...
Read more >
Solucionar el error en Android Calling startActivity from ...
Calling startActivity from outside of an Activity context requires the ... Intent sendIntent = new Intent(); sendIntent.setAction(Intent.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found