单击我的应用程序的按钮时,我正在尝试使用手机上的默认应用程序打开一个 xml 文件。在谷歌之后我发现并遵循了这个:http ://www.androidsnippets.com/open-file-with-default-application-using-intents ,我的代码就像:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(_file), "application/*");
startActivity(intent);
它可以在我的手机上运行,但是 logcat 出现了一些错误:
01-07 02:42:48.242: E/ActivityThread(11280): Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@417ffc78 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-07 02:42:48.242: E/ActivityThread(11280): android.app.IntentReceiverLeaked: Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@417ffc78 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:763)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:567)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1055)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1042)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1036)
01-07 02:42:48.242: E/ActivityThread(11280): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:341)
01-07 02:42:48.242: E/ActivityThread(11280): at com.android.internal.content.PackageMonitor.register(PackageMonitor.java:65)
01-07 02:42:48.242: E/ActivityThread(11280): at com.android.internal.app.ResolverActivity.onCreate(ResolverActivity.java:99)
01-07 02:42:48.242: E/ActivityThread(11280): at com.android.internal.app.ChooserActivity.onCreate(ChooserActivity.java:53)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.Activity.performCreate(Activity.java:4467)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1925)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1986)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.ActivityThread.access$600(ActivityThread.java:128)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1152)
01-07 02:42:48.242: E/ActivityThread(11280): at android.os.Handler.dispatchMessage(Handler.java:99)
01-07 02:42:48.242: E/ActivityThread(11280): at android.os.Looper.loop(Looper.java:137)
01-07 02:42:48.242: E/ActivityThread(11280): at android.app.ActivityThread.main(ActivityThread.java:4449)
01-07 02:42:48.242: E/ActivityThread(11280): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 02:42:48.242: E/ActivityThread(11280): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 02:42:48.242: E/ActivityThread(11280): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
01-07 02:42:48.242: E/ActivityThread(11280): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
01-07 02:42:48.242: E/ActivityThread(11280): at dalvik.system.NativeStart.main(Native Method)
我没有注册任何东西,也不知道如何解决“您是否错过了对 unregisterReceiver() 的调用”,我该如何更改我的代码?