Error starting “com.twitter.android.PostActivity”

匆匆过客 提交于 2019-12-07 11:59:24

问题


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


回答1:


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



回答2:


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




回答3:


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



回答4:


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



来源:https://stackoverflow.com/questions/19681018/error-starting-com-twitter-android-postactivity

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