<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PlatformException (PlatformException(error, Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?, null))"><pre class="notranslate"><code class="notranslate">PlatformException (PlatformException(error, Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?, null))
</code></pre></div>
<p dir="auto">after downgrading to 3.0.0 it Works well</p>
<p dir="auto">I cloned the Flutter repo today to check why following error occur when using url_launcher. I have tried latest package and also placing <code class="notranslate">any</code>. Most importantly when it is not working I just copy pasted the doc example: <a href="https://flutter.io/docs/development/packages-and-plugins/using-packages" rel="nofollow">https://flutter.io/docs/development/packages-and-plugins/using-packages</a> but still I get the same error message, no luck.</p>
<h2 dir="auto">Log</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="E/MethodChannel#plugins.flutter.io/url_launcher(31054): Failed to handle method call
E/MethodChannel#plugins.flutter.io/url_launcher(31054): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.app.ContextImpl.startActivity(ContextImpl.java:1140)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.app.ContextImpl.startActivity(ContextImpl.java:1127)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.content.ContextWrapper.startActivity(ContextWrapper.java:311)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at io.flutter.plugins.urllauncher.UrlLauncherPlugin.onMethodCall(UrlLauncherPlugin.java:61)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.os.MessageQueue.nativePollOnce(Native Method)E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.os.MessageQueue.next(MessageQueue.java:138)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.os.Looper.loop(Looper.java:150)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.app.ActivityThread.main(ActivityThread.java:5398)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at java.lang.reflect.Method.invokeNative(Native Method)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at java.lang.reflect.Method.invoke(Method.java:515)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:940)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at dalvik.system.NativeStart.main(Native Method)
E/flutter (31054): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (31054): PlatformException(error, Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?, null)
E/flutter (31054): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter (31054): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292:18)
E/flutter (31054): &lt;asynchronous suspension&gt;
E/flutter (31054): #2      launch (package:url_launcher/url_launcher.dart:66:19)
E/flutter (31054): #3      DemoPage.launchURL (package:nov29long/main.dart:19:5)
E/flutter (31054): #4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (31054): #5      _InkResponseState.build.&lt;anonymous closure&gt; (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (31054): #6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (31054): #7      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (31054): #8      TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
E/flutter (31054): #9      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
E/flutter (31054): #10     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter (31054): #11     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter (31054): #12     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19)
E/flutter (31054): #13     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
E/flutter (31054): #14     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
E/flutter (31054): #15     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (31054): #16     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter (31054): #17     _invoke1 (dart:ui/hooks.dart:168:13)
E/flutter (31054): #18     _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)"><pre class="notranslate"><code class="notranslate">E/MethodChannel#plugins.flutter.io/url_launcher(31054): Failed to handle method call
E/MethodChannel#plugins.flutter.io/url_launcher(31054): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.app.ContextImpl.startActivity(ContextImpl.java:1140)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.app.ContextImpl.startActivity(ContextImpl.java:1127)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.content.ContextWrapper.startActivity(ContextWrapper.java:311)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at io.flutter.plugins.urllauncher.UrlLauncherPlugin.onMethodCall(UrlLauncherPlugin.java:61)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.os.MessageQueue.nativePollOnce(Native Method)E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.os.MessageQueue.next(MessageQueue.java:138)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.os.Looper.loop(Looper.java:150)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at android.app.ActivityThread.main(ActivityThread.java:5398)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at java.lang.reflect.Method.invokeNative(Native Method)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at java.lang.reflect.Method.invoke(Method.java:515)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:940)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
E/MethodChannel#plugins.flutter.io/url_launcher(31054):         at dalvik.system.NativeStart.main(Native Method)
E/flutter (31054): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (31054): PlatformException(error, Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?, null)
E/flutter (31054): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter (31054): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292:18)
E/flutter (31054): &lt;asynchronous suspension&gt;
E/flutter (31054): #2      launch (package:url_launcher/url_launcher.dart:66:19)
E/flutter (31054): #3      DemoPage.launchURL (package:nov29long/main.dart:19:5)
E/flutter (31054): #4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (31054): #5      _InkResponseState.build.&lt;anonymous closure&gt; (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (31054): #6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (31054): #7      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (31054): #8      TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
E/flutter (31054): #9      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
E/flutter (31054): #10     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter (31054): #11     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter (31054): #12     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19)
E/flutter (31054): #13     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
E/flutter (31054): #14     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
E/flutter (31054): #15     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (31054): #16     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter (31054): #17     _invoke1 (dart:ui/hooks.dart:168:13)
E/flutter (31054): #18     _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.11.12, on Microsoft Windows [Version 10.0.14393], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    X Android license status unknown.
[√] Android Studio (version 3.1)
[√] IntelliJ IDEA Community Edition (version 2017.3)
[√] IntelliJ IDEA Community Edition (version 2018.1)
[√] VS Code, 32-bit edition
[√] VS Code, 64-bit edition (version 1.29.1)
[√] Connected device (1 available)

! Doctor found issues in 1 category.
"><pre class="notranslate"><code class="notranslate">Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.11.12, on Microsoft Windows [Version 10.0.14393], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    X Android license status unknown.
[√] Android Studio (version 3.1)
[√] IntelliJ IDEA Community Edition (version 2017.3)
[√] IntelliJ IDEA Community Edition (version 2018.1)
[√] VS Code, 32-bit edition
[√] VS Code, 64-bit edition (version 1.29.1)
[√] Connected device (1 available)

! Doctor found issues in 1 category.

</code></pre></div>