我已使用我的 Android 应用程序在 Twitter 上成功共享了 text/img,但现在我需要通过我的应用程序在 Twitter 上共享 VIDEO。有没有可能的库来实现这一目标?欢迎就如何通过我的应用程序在 Twitter 上分享视频提出任何建议。
PS:最好能提供一些教程的链接。
最佳答案
即兴创作AndroidEnthusiastic's回答,下面是通过安卓应用在推特上分享视频的工作代码
File f=new File(filepath);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("video/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
final PackageManager pm = getActivity().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))
{
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);
getActivity().getApplicationContext().startActivity(shareIntent);
break;
}
}
其中 filepath
是视频存储在设备存储中的路径,如“/storage/emulated/0/Videos/VID_20151011_115238.mp4
”
关于android - 通过 Android 应用程序在 Twitter 上分享视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14972368/