Android launch Twitter intent

前端 未结 3 559
生来不讨喜
生来不讨喜 2020-12-15 19:03

I used below code for launching Twitter through intent but it\'s not working. I have twitter app installed on my phone.

Intent shareIntent = new Intent(andro         


        
3条回答
  •  一整个雨季
    2020-12-15 19:16

    I was using the com.twitter.android.composer.ComposerActivity to post text and images since 2016. But started to receive crash reports from users some time ago:

    Fatal Exception: android.content.ActivityNotFoundException Unable to find explicit activity class {com.twitter.android/com.twitter.android.composer.ComposerActivity}; have you declared this activity in your AndroidManifest.xml?

    The issue was caused by renaming
    com.twitter.android.composer.ComposerActivity
    to
    com.twitter.composer.ComposerActivity
    inside Twitter app.

    The issue was resolved since I changed activity name to com.twitter.composer.ComposerActivity.

    And I use the following code to post images with text to Twitter:

    ShareCompat.IntentBuilder.from(activity)
        .setText(getTextToShare())
        .setStream(getImageUriToShare())
        .setType("image/png")
        .getIntent().addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
        .setClassName("com.twitter.android", "com.twitter.composer.ComposerActivity");
    

提交回复
热议问题