Android意图分享在Facebook上分享一个视频网址 [英] Android intent share to share a video url on facebook

查看:586
本文介绍了Android意图分享在Facebook上分享一个视频网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Android应用程序中,我想在Facebook上分享一个视频网址,我已经尝试了两种方式。一个:

  Intent shareIntent = new Intent(Intent.ACTION_SEND); 
shareIntent.setType(text / plain);
shareIntent.putExtra(Intent.EXTRA_TEXT,videoPathURL [position]);
shareIntent.setPackage(com.facebook.katana);
activity.startActivity(shareIntent);

第一种方式只能在Facebook上分享一个像https:// ...一样的链接您可以在浏览器上单击并打开一个将播放视频的新标签。



第二个:

  Intent sharingIntent = new Intent(Intent.ACTION_SEND); 
sharingIntent.setType(video / *);
Uri uri = Uri.parse(videoPathURL [position]);
sharingIntent.putExtra(Intent.EXTRA_STREAM,uri);
sharingIntent.setPackage(com.facebook.katana);
activity.startActivity(sharingIntent);

这个不共享任何东西。
任何人都有一个想法来解决这个问题?
我希望视频在Facebook上像视频一样显示,而不是像URL。



可以吗?或者我唯一的选择是共享网址吗?请帮助我这个



提前感谢

解决方案

几个小时试图找出如何使其在Facebook,YouTube,instagram和whatsapp上传和分享视频的工作。这是为我工作的代码。将录制的视频从您的应用程序上传到社交媒体应用程序



在处理视频时尝试使用ContentValues。

  ContentValues content = new ContentValues(4); 
content.put(Video.VideoColumns.DATE_ADDED,
System.currentTimeMillis()/ 1000);
content.put(Video.Media.MIME_TYPE,video / mp4);
content.put(MediaStore.Video.Media.DATA,your_path_to_video);
ContentResolver resolver = getBaseContext()。getContentResolver();
Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,content);

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType(video / *);
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,Title);
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,uri);
startActivity(Intent.createChooser(sharingIntent,share:)); `


On my android app, I want to share a video url on facebook, i've tried two ways. One:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
                    shareIntent.setType("text/plain");
                    shareIntent.putExtra(Intent.EXTRA_TEXT, videoPathURL[position]);
                    shareIntent.setPackage("com.facebook.katana");
                    activity.startActivity(shareIntent);

This first way only share on facebook a link like text "https://..." so you can click and open a new tab on browser that will play the video.

Second:

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                    sharingIntent.setType("video/*");
                    Uri uri = Uri.parse(videoPathURL[position]);
                    sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
                    sharingIntent.setPackage("com.facebook.katana");
                    activity.startActivity(sharingIntent);

This one doesn't share anything. Anyone have an idea to solve this ? I want the video to be displayed on facebook like a video and not like an URL.

Is it possible ? Or my only option is sharing the url like so ? Please help me with this

Thanks in advance

解决方案

After several hours of trying to find out how to make it work for uploading and sharing video on facebook, youtube, instagram and whatsapp. this is the code that worked for me. Uploading recorded video from your application to social media applications

try using ContentValues when dealing with videos.

ContentValues content = new ContentValues(4);
        content.put(Video.VideoColumns.DATE_ADDED,
        System.currentTimeMillis() / 1000);
        content.put(Video.Media.MIME_TYPE, "video/mp4");
        content.put(MediaStore.Video.Media.DATA, "your_path_to_video");
        ContentResolver resolver = getBaseContext().getContentResolver();
        Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, content);

        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("video/*");
        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Title");
        sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,uri);
        startActivity(Intent.createChooser(sharingIntent,"share:")); `

这篇关于Android意图分享在Facebook上分享一个视频网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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