it视频网站:Android意图分享在Facebook上分享一个视频网址(Android intent share to share a video url on facebook)

  5月8日星座天鏂楃綏h缃戠珯,蝎运势it视频网站:Android意图分享在Facebook上分享一个视频网址(Android intent share to share a video url on facebook)-U9SEO

  On my android app, I susan星座运势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);

  星座大师2016年运势 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:")); `