通过安卓应用在推特上分享视频 [英] Share video on twitter via android app

查看:84
本文介绍了通过安卓应用在推特上分享视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 twitter 上成功地与我的 android 应用程序共享了 text/img,但现在我需要通过我的应用程序在 Twitter 上共享 VIDEO.有没有可能的库来实现这一目标?欢迎就如何通过我的应用程序在 Twitter 上分享视频提出任何建议.

I successfully shared text/img on twitter with my android application, but now I've need to share VIDEO on Twitter via my app. Is there any possible lib to achieve that? Any suggestions on how to share video on twitter via my application are welcome.

PS:一些教程的链接会很棒.

PS: A link to some tutorial would be great.

推荐答案

Improvising the AndroidEnthusiastic's 的答案,下面是工作代码用于通过 android 应用在 twitter 上分享视频

Improvising the AndroidEnthusiastic's answer,below is working code for Sharing video on twitter via android app

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"

where filepath is the path of video stored in device storage like "/storage/emulated/0/Videos/VID_20151011_115238.mp4"

这篇关于通过安卓应用在推特上分享视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆