我试着
launch("tel://21213123123")
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误!
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))
Run Code Online (Sandbox Code Playgroud)
在这个文件中
message_codecs.dart
Run Code Online (Sandbox Code Playgroud)
这是我的错误日志
E/MethodChannel#plugins.flutter.io/url_launcher(26131): Failed to handle method call
E/MethodChannel#plugins.flutter.io/url_launcher(26131): 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(26131): at android.app.ContextImpl.startActivity(ContextImpl.java:672)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at android.app.ContextImpl.startActivity(ContextImpl.java:659)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at android.content.ContextWrapper.startActivity(ContextWrapper.java:331)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at io.flutter.plugins.urllauncher.UrlLauncherPlugin.onMethodCall(UrlLauncherPlugin.java:61)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at android.os.Looper.loop(Looper.java:135)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at android.app.ActivityThread.main(ActivityThread.java:5468)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:781)
E/MethodChannel#plugins.flutter.io/url_launcher(26131): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:671)
Run Code Online (Sandbox Code Playgroud)
小智 5
新版本的urlLauncher 4.0.2插件遇到了同样的问题
我降级到3.0.3并且一切正常,因此存储库中可能存在错误.
pubspec.yaml
url_launcher: 3.0.3
Run Code Online (Sandbox Code Playgroud)
示例代码(取自git repo,但它适用于3.0.3)
https://github.com/flutter/plugins/tree/master/packages/url_launcher
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
void main() {
runApp(Scaffold(
body: Center(
child: RaisedButton(
onPressed: _launchURL,
child: Text('Show Flutter homepage'),
),
),
));
}
_launchURL() async {
const url = 'https://flutter.io';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
Run Code Online (Sandbox Code Playgroud)
对于插件的所有可用版本,请参见此处. https://pub.dartlang.org/packages/url_launcher#-changelog-tab-
| 归档时间: |
|
| 查看次数: |
1061 次 |
| 最近记录: |