嗨,我是Android的新手,在我的应用程序中,我录制了视频,当我收到录制的视频意图数据时,我的LG手机和我的Nexus出现异常这个问题不会出现
请一位有人帮助我
private void recordVideo() {
try {
String tempTimestamp = "" + TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
File mediaFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/" + tempTimestamp + ".mp4");
fileName = tempTimestamp + ".mp4";
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
fileUri = Uri.fromFile(mediaFile);
System.out.println("file uri is====>" + fileUri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(intent, Constants.VIDEO_REQUEST_CODE);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
if (requestCode == Constants.VIDEO_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
if (data.getData() != null) {
} else {
if (data.getExtras().get("data") != null) {
data.getExtras().get("data");
}
}
}
}
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
11-05 05:06:12.859 26942-26942/com.ensis.epatient W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Bundle android.content.Intent.getExtras()' on a null object reference
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at com.ensis.epatient.Gallery.VideosAttachmentActivity.onActivityResult(VideosAttachmentActivity.java:283)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at android.app.Activity.dispatchActivityResult(Activity.java:6258)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:3685)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:3732)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at android.app.ActivityThread.access$1300(ActivityThread.java:162)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at android.os.Looper.loop(Looper.java:135)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5431)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at java.lang.reflect.Method.invoke(Native Method)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:914)
11-05 05:06:12.869 26942-26942/com.ensis.epatient I/Activity: Activity.onPostResume() called
11-05 05:06:12.869 26942-26942/com.ensis.epatient W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
答案 0 :(得分:0)
尝试更改此内容:
read,write,delete
为:
if (data.getData() != null) {
} else {
if (data.getExtras().get("data") != null) {
data.getExtras().get("data");
}
}
答案 1 :(得分:0)
当您使用lda = models.LdaModel.load('lda.model')
for i in range(0, lda.num_topics):
with open('output_file.txt', 'w') as outfile:
outfile.write('{}\n'.format('Topic #' + str(i + 1) + ': '))
for word, prob in lda.show_topic(i, topn=20):
outfile.write('{}\n'.format(word.encode('utf-8')))
outfile.write('\n')
作为相机意图时,uotput存储在该文件中。 Topic #69:
pet
dental
tooth
adopt
animal
puppy
rescue
dentist
adoption
animal
shelter
pet
dentistry
vet
paw
pup
patient
mix
foster
owner
Topic #70:
periscope
disneyland
disney
snapchat
brandon
britney
periscope
periscope
replay
britneyspear
buffaloexchange
britneyspear
https
meerkat
blab
periscope
kxci
toni
disneyland
location
中返回的数据将为空。
您可以使用MediaStore.EXTRA_OUTPUT
传递的onActivityResult()
来访问相机拍摄的图像或视频。
fileUri