gpt4 book ai didi

java - Android kitkat API 19,Intent.ACTION_VIEW 不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 15:20:38 25 4
gpt4 key购买 nike

我使用这行代码在手机默认浏览器中打开URL

startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://www.myurl.com")));

现在在 Android KitKat 上,使用 GoogleApi 19 在模拟器设备上运行我的项目,屏幕变黑并出现“浏览器停止工作”错误...

这个新版本和我的代码有什么问题?

这是日志

12-06 10:49:53.176: E/WindowManager(384): Starting window AppWindowToken{b468a060  token=Token{b4394958 ActivityRecord{b409c568 u0 com.android.browser/.BrowserActivity t15}}} timed out
12-06 10:50:43.776: E/NativeDaemonConnector.ResponseQueue(384): Timeout waiting for response
12-06 10:50:43.776: E/VoldConnector(384): timed-out waiting for response to 6 volume mkdirs /storage/sdcard/Android/data/com.android.browser/files/
12-06 10:50:43.806: D/AndroidRuntime(1891): Shutting down VM
12-06 10:50:43.816: W/dalvikvm(1891): threadid=1: thread exiting with uncaught exception (group=0xb3a6cb90)
12-06 10:50:43.846: E/AndroidRuntime(1891): FATAL EXCEPTION: main
12-06 10:50:43.846: E/AndroidRuntime(1891): Process: com.android.browser, PID: 1891
12-06 10:50:43.846: E/AndroidRuntime(1891): java.lang.RuntimeException: Unable to get provider com.android.browser.provider.SnapshotProvider: java.lang.NullPointerException
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.app.ActivityThread.installProvider(ActivityThread.java:4774)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4366)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4306)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.app.ActivityThread.access$1400(ActivityThread.java:135)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1457)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.os.Handler.dispatchMessage(Handler.java:102)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.os.Looper.loop(Looper.java:137)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-06 10:50:43.846: E/AndroidRuntime(1891): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 10:50:43.846: E/AndroidRuntime(1891): at java.lang.reflect.Method.invoke(Method.java:515)
12-06 10:50:43.846: E/AndroidRuntime(1891): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-06 10:50:43.846: E/AndroidRuntime(1891): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-06 10:50:43.846: E/AndroidRuntime(1891): at dalvik.system.NativeStart.main(Native Method)
12-06 10:50:43.846: E/AndroidRuntime(1891): Caused by: java.lang.NullPointerException
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.os.Parcel.readException(Parcel.java:1467)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.os.Parcel.readException(Parcel.java:1415)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.os.storage.IMountService$Stub$Proxy.mkdirs(IMountService.java:750)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.app.ContextImpl.ensureDirsExistOrFilter(ContextImpl.java:2160)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.app.ContextImpl.getExternalFilesDirs(ContextImpl.java:856)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.app.ContextImpl.getExternalFilesDir(ContextImpl.java:839)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.content.ContextWrapper.getExternalFilesDir(ContextWrapper.java:210)
12-06 10:50:43.846: E/AndroidRuntime(1891): at com.android.browser.provider.SnapshotProvider.getOldDatabasePath(SnapshotProvider.java:116)
12-06 10:50:43.846: E/AndroidRuntime(1891): at com.android.browser.provider.SnapshotProvider.migrateToDataFolder(SnapshotProvider.java:123)
12-06 10:50:43.846: E/AndroidRuntime(1891): at com.android.browser.provider.SnapshotProvider.onCreate(SnapshotProvider.java:137)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.content.ContentProvider.attachInfo(ContentProvider.java:1589)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.content.ContentProvider.attachInfo(ContentProvider.java:1560)
12-06 10:50:43.846: E/AndroidRuntime(1891): at android.app.ActivityThread.installProvider(ActivityThread.java:4771)
12-06 10:50:43.846: E/AndroidRuntime(1891): ... 12 more
12-06 10:50:43.856: W/ActivityManager(384): Force finishing activity com.android.browser/.BrowserActivity
12-06 10:50:43.886: W/ActivityManager(384): Force finishing activity com.irideprogetti.senigallia.it/.MainEventi

最佳答案

对我有用

 public static void openBrowser(final Context context, String url)
{
if (!url.startsWith("http://") && !url.startsWith("https://"))
{
url = "http://" + url;
}

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(Intent.createChooser(intent, "Chose browser"));
}

关于java - Android kitkat API 19,Intent.ACTION_VIEW 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20427897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com