ShareCompat IntentBuilder每次在Android 4上崩溃 [英] ShareCompat IntentBuilder crashing every time on Android 4
问题描述
在我的一项活动中,我正在使用ShareCompat IntentBuilder允许用户共享一些文本:
In one of my activities, I am using the ShareCompat IntentBuilder to allow users to share some text:
ShareCompat.IntentBuilder
.from(this)
.setText("The shared text")
.setType("text/plain")
.setChooserTitle("Share to")
.startChooser();
在Android 5及更高版本上,此工作正常,但在Android 4上,出现以下崩溃每次:
On Android 5 and above, this works as expected, but on Android 4, I have the following crash every time:
android.app.SuperNotCalledException: Activity {android/com.android.internal.app.ChooserActivity} did not call through to super.onStop()
at android.app.Activity.performStop(Activity.java:4606)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3071)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3130)
at android.app.ActivityThread.access$1200(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1180)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
不确定为什么会这样,感谢您的帮助,谢谢!
Not sure why this is happening, any help would be appreciated, thanks!
推荐答案
Hmmmm ...我将您的代码粘贴到新的应用程序中,在4.0.3模拟器上运行,然后打开Messenger应用程序。这是4.0.3模拟器上唯一知道如何共享文本的应用。 LogCat中有一个堆栈跟踪,其中 ChooserActivity
泄漏了 IntentReceiver
,但我没收到您的 onStop()
问题。
Hmmmm... I pasted your code into a new application, ran it on a 4.0.3 emulator, and the Messenger app opened. That's the only app on a 4.0.3 emulator that knows how to share text. There's a stack trace in LogCat where ChooserActivity
leaked an IntentReceiver
, but I don't get your onStop()
problem.
您的代码中没有错误。我的猜测是,这是您的模拟器映像设置的问题。您可以尝试创建一个新的映像,确保您具有Android SDK Manager的所有最新更新(尽管此映像可能已经有一段时间没有更新了。)。
There is nothing in your code that is wrong. My guess is that this is some issue with your emulator image setup. You might try creating a fresh image, making sure that you have all the latest updates from the Android SDK Manager (though this image may not have been updated in quite some time).
如果您可以在示例项目中始终如一地重现该问题,因为您正在模拟器上找到它,请提出问题,附加项目并显示堆栈跟踪。
If you can consistently reproduce the problem with a sample project, since you are getting it on the emulator, file an issue, attaching your project and showing the stack trace.
除此之外,我真的怀疑这是您在真正的Android设备上会遇到的问题。
Beyond that, I really doubt that this is a problem that you will experience on real Android devices.
这篇关于ShareCompat IntentBuilder每次在Android 4上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!