Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
270 views
in Technique[技术] by (71.8m points)

android youtube upload using intent

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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...