Android kitkat API 19,Intent.ACTION_VIEW无效

时间:2013-12-06 15:40:33

标签: java android api android-4.4-kitkat

我已使用此行代码在手机的默认浏览器中打开网址

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

1 个答案:

答案 0 :(得分:0)

为我工作

 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"));
    }