Reputation: 3
I am encountering crashes on Twitter 8.11.0 using ACTION_SEND if there is no logged in user on Twitter App itself.
I have tried it with lower versions of twitter such as Twitter 8.10.0 and it's working properly.
Here is my current code
Intent tweetIntent = new Intent(Intent.ACTION_SEND);
tweetIntent.putExtra(Intent.EXTRA_TEXT, checkStringFormat());
tweetIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
tweetIntent.setType("text/plain");
PackageManager packManager = getPackageManager();
List<ResolveInfo> resolvedInfoList = packManager.queryIntentActivities(tweetIntent, PackageManager.MATCH_DEFAULT_ONLY);
boolean resolved = false;
for (ResolveInfo resolveInfo : resolvedInfoList) {
if (resolveInfo.activityInfo.packageName.startsWith("com.twitter.android")) {
tweetIntent.setClassName(resolveInfo.activityInfo.packageName,
resolveInfo.activityInfo.name);
resolved = true;
break;
}
}
if (resolved) {
startActivity(tweetIntent);
} else {
routeToWebView();
}
Normally if there is no session in twitter app, the ACTION_SEND intent would route you to twitter's login page.
Here is the error message I am receiving
2019-09-05 15:03:54.409 29626-29626/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.twitter.android, PID: 29626
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.twitter.android/com.twitter.composer.ComposerActivity}: java.lang.IllegalStateException: NullableUtils.checkIsNotNull(userInfo.userName) must not be null
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3303)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.IllegalStateException: NullableUtils.checkIsNotNull(userInfo.userName) must not be null
at o16.a(Twttr:1)
at c16.<init>(Twttr:5)
at d16.get(Twttr:2)
at d16.get(Twttr:1)
at jqb.get(Twttr:6)
at com.twitter.composer.selfthread.l0.get(Twttr:2)
at com.twitter.composer.selfthread.l0.get(Twttr:1)
at jqb.get(Twttr:6)
at com.twitter.android.app.di.DaggerTwitterApplicationObjectGraph$Scythe$Component$d$x3$b.g(Twttr:1)
at bt3.a(Twttr:12)
at vs3.onCreate(Twttr:2)
at em3.onCreate(Twttr:2)
at ro3.onCreate(Twttr:1)
at android.app.Activity.performCreate(Activity.java:7383)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3256)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Upvotes: 0
Views: 97