Error starting “com.twitter.android.PostActivity”

2019-05-06 21:20发布

I call a intent to Twitter to share a text. Without changing the code, from one day to another, this call has stopped working.

The Intent is:

Intent share = new Intent(Intent.ACTION_VIEW);
    share.setClassName("com.twitter.android",
            "com.twitter.android.PostActivity");
    share.setType("text/plain");

    share.putExtra(Intent.EXTRA_TEXT, getString(R.string.app_share_twitter));

    share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    startActivityForResult(share, SHARE_TWITTER);

Thanks

4条回答
女痞
2楼-- · 2019-05-06 21:57

In July 2014, I've found that the Twitter activity has once again changed name, it is now called "com.twitter.android.composer.ComposerActivity".

查看更多
Bombasti
3楼-- · 2019-05-06 21:57

The Twitter activity has once again changed name, it is now called "com.twitter.android.composer.ComposerShareActivity".

查看更多
小情绪 Triste *
4楼-- · 2019-05-06 22:00

They have changed the activity that handle it...you can try now with setting this to your Intent:

   intent.setClassName("com.twitter.android", 
                     "com.twitter.composer.SelfThreadComposerActivity");
查看更多
祖国的老花朵
5楼-- · 2019-05-06 22:07

The problem is the last Twitter Android app update (4.1.9)

The action that you call, have been changed to "com.twitter.applib.PostActivity". Try this to prevent the Exception launched in old/new Twitter versions:

try{
    startActivityForResult(share, SHARE_TWITTER);
}catch(Throwable e){
    share.setClassName("com.twitter.android", "com.twitter.applib.PostActivity");
    try{
        startActivityForResult(share, SHARE_TWITTER);
    }catch(Throwable e2){
        Log.e(TAG, e2.toString());                                              
    }}
查看更多
登录 后发表回答