ShareCompat IntentBuilder crashing every time on Android 4

本秂侑毒 提交于 2019-12-13 05:45:06

问题


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();

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!


回答1:


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.

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.

Beyond that, I really doubt that this is a problem that you will experience on real Android devices.



来源:https://stackoverflow.com/questions/39088261/sharecompat-intentbuilder-crashing-every-time-on-android-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!