我正在使用下面的代碼在twitter上分享視頻。它工作正常,如果應用程序安裝在設備上,但不工作,如果應用程序不存在。我可以在Twitter上分享視頻,即使如果應用程序未安裝在設備中?Twitter分享,如果應用程序沒有安裝
File f = new File(extras.getString("filepath"));
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("video/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
final PackageManager pm = mActivity.getApplicationContext().getPackageManager();
final List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList) {
if (("com.twitter.android.composer.ComposerActivity".equals(app.activityInfo.name)) || ("com.twitter.android.PostActivity".equals(app.activityInfo.name))) {
final ActivityInfo activity = app.activityInfo;
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
shareIntent.setComponent(name);
mActivity.getApplicationContext().startActivity(shareIntent);
break;
}
}
與twitter無關的方式都完全不同 –
@Nic我可以通過Tweet Composer分享視頻嗎?我可以發佈一些代碼嗎? –
我可以分享視頻wid TweetComposer嗎? –