4
我使用此代码,开始使用官方Twitter应用在Twitter上发布:如何使用意向,然后返回给你的应用程序使用官方的Twitter应用程序发布鸣叫?
public static boolean canReceiveIntent (Intent intent, Context c) {
PackageManager packageManager = c.getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;
return isIntentSafe;
}
它工作正常,但Twitter的应用程序:使用它与之前
Intent twitterIntent = new Intent(Intent.ACTION_VIEW); //Intent.ACTION_VIEW
twitterIntent.setAction("android.intent.action.SEND");
twitterIntent.setFlags(0x3000000);
twitterIntent.setType("text/plain");
twitterIntent.setClassName("com.twitter.android", "com.twitter.android.PostActivity");
twitterIntent.putExtra(Intent.EXTRA_TEXT, ("Random post"));
startActivity(twitterIntent);
我也检查,如果这个目的是提供发布推文后(在订阅源上)后仍然打开。我也尝试使用startActivityForresult(),但它崩溃的错误:
java.lang.RuntimeException: android.util.AndroidRuntimeException: FORWARD_RESULT_FLAG used while also requesting a result
如何在发布tweet后返回到我的应用程序?