Android - Google+ share status fails

拥有回忆 提交于 2019-12-04 10:47:27

I see this same error using google-play-services 6.1.71. Edu Barbas above has the correct answer, using ShareCompat.IntentBuilder seems to resolve the issue. I don't have enough points to comment on his answer, but I wanted to add that the building of the intent and starting of the share activity is a little different:

      Intent shareIntent = ShareCompat.IntentBuilder.from(TheCurrentActivity.this)
                .setType("text/plain")
                .setText(statusMessage)
                .getIntent()
                .setPackage("com.google.android.apps.plus");

        startActivityForResult(shareIntent, 0);

Leaving off the setPackage("com.google.android.apps.plus") line brings up a general android share dialog, allowing you to share via email, bluetooth, and sms, in addition to google plus. Adding the setPackage line allows you to bypass that dialog and share exclusively through google plus.

I experienced the same behavior after we updated the Google Play Services library in my project. I launched the G+ share dialog via PlusShare.Builder, which made the app crash. I solved the issue by switching to ShareCompat.IntentBuilder instead (the share dialog is exactly the same).

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