Android的YouTube上传使用意图 [英] android youtube upload using intent

查看:116
本文介绍了Android的YouTube上传使用意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 意向意图=新的意图();

intent.setAction(Intent.ACTION_SEND);
intent.setType(视频/ 3GPP);
intent.putExtra(Intent.EXTRA_STREAM,videoURI);
startActivity(Intent.createChooser(原意通过上传影像));
 

我用上面的code为3gp的视频上传到YouTube被解雇的意图

但它抛出以下异常。

我不明白什么是日期例外,媒体上传的关系

  05-04 13:04:59.315:ERROR / AndroidRuntime(10671):致命异常:螺纹12
05-04 13:04:59.315:ERROR / AndroidRuntime(10671):显示java.lang.NullPointerException
05-04 13:04:59.315:ERROR / AndroidRuntime(10671):在java.util.Calendar.setTime(Calendar.java:1325)
05-04 13:04:59.315:ERROR / AndroidRuntime(10671):在java.text.SimpleDateFormat.formatImpl(SimpleDateFormat.java:536)
05-04 13:04:59.315:ERROR / AndroidRuntime(10671):在java.text.SimpleDateFormat.format(SimpleDateFormat.java:818)
05-04 13:04:59.315:ERROR / AndroidRuntime(10671):在java.text.DateFormat.format(DateFormat.java:376)
05-04 13:04:59.315:ERROR / AndroidRuntime(10671):在com.google.android.apps.uploader.clients.youtube.YouTubeSettingsActivity.a(的SourceFile:183)
05-04 13:04:59.315:ERROR / AndroidRuntime(10671):在com.google.android.apps.uploader.clients.SettingsActivity.b(的SourceFile:43)
05-04 13:04:59.315:ERROR / AndroidRuntime(10671):在com.google.android.apps.uploader.clients.j.run(的SourceFile:348)
05-04 13:04:59.315:ERROR / AndroidRuntime(10671):在java.lang.Thread.run(Thread.java:1019)
 

解决方案

我碰到了同样的错误,当我用 Uri.fromFile()获得我的视频URI 。该解决方案是使用的ContentProvider 创建URI:

  ContentValues​​内容=新ContentValues​​(4);
content.put(Video.VideoColumns.TITLE,测试);
content.put(Video.VideoColumns.DATE_ADDED,
System.currentTimeMillis的()/ 1000);
content.put(Video.Media.MIME_TYPE,视频/ MP4);
content.put(MediaStore.Video.Media.DATA/sdcard/myvideo.mp4);
ContentResolver的解析器=的getContext()getContentResolver()。
开放的我们的uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,内容);
 

Intent intent = new Intent();

intent.setAction(Intent.ACTION_SEND);
intent.setType("video/3gpp");
intent.putExtra(Intent.EXTRA_STREAM, videoURI);
startActivity(Intent.createChooser(intent,"Upload video via:"));

I used above code to upload 3gp video to youtube by firing intent

but it throws following exception.

I dont understand what is the relationship between the date exception and media uploading

05-04 13:04:59.315: ERROR/AndroidRuntime(10671): FATAL EXCEPTION: Thread-12
05-04 13:04:59.315: ERROR/AndroidRuntime(10671): java.lang.NullPointerException
05-04 13:04:59.315: ERROR/AndroidRuntime(10671):     at java.util.Calendar.setTime(Calendar.java:1325)
05-04 13:04:59.315: ERROR/AndroidRuntime(10671):     at java.text.SimpleDateFormat.formatImpl(SimpleDateFormat.java:536)
05-04 13:04:59.315: ERROR/AndroidRuntime(10671):     at java.text.SimpleDateFormat.format(SimpleDateFormat.java:818)
05-04 13:04:59.315: ERROR/AndroidRuntime(10671):     at java.text.DateFormat.format(DateFormat.java:376)
05-04 13:04:59.315: ERROR/AndroidRuntime(10671):     at com.google.android.apps.uploader.clients.youtube.YouTubeSettingsActivity.a(SourceFile:183)
05-04 13:04:59.315: ERROR/AndroidRuntime(10671):     at com.google.android.apps.uploader.clients.SettingsActivity.b(SourceFile:43)
05-04 13:04:59.315: ERROR/AndroidRuntime(10671):     at com.google.android.apps.uploader.clients.j.run(SourceFile:348)
05-04 13:04:59.315: ERROR/AndroidRuntime(10671):     at java.lang.Thread.run(Thread.java:1019)

解决方案

I ran into the same bug when I used Uri.fromFile() for obtaining URI of my video. The solution was using a ContentProvider for creating URI:

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

这篇关于Android的YouTube上传使用意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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