我正在使用下面的代码在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吗? –