Android相机的图片和视频 [英] Android Camera for Picture and Video
问题描述
我想在我的Android应用程序启动摄像头的活动,我知道该怎么做。我想问一下当相机活动结束后,我怎么能检查,如果它是图片或由用户拍摄的视频?
I want to start camera activity in my android app and I know how to do that. I want to ask when the camera activity finishes, how can I check as if it was the picture or the video taken by the user?
更新时间:
我在它要求两件事情的对话框。
I have a dialog where it asks 2 things.
- 新照片或视频
- 现有照片或视频
如果它没有。 1,这意味着照相机将被启动,并且用户可以拍摄照片或视频,它将返回到活动
If it's no. 1, it means camera will be started and user can either take a picture or the video and it will return to the activity.
如果是2号,它的意思是画廊将有图片和视频供用户选择一个开始,将返回到活动。
If it's no.2, it mean gallery will be started having pictures and videos for a user to select one and will return back to the activity.
推荐答案
您好Umair,
我做过这种类型的应用我搜查了许多时间,但让我改变了你我的菜单和放我没有得到任何妥善的解决办法;他们现在
1)拍摄新照片
2)采取新的视频
3)现有的图像/视频
Hello Umair, I have done this type of application I searched many time but I didn't get any proper solution so I changed your my menu & they are now 1)Take New Photo 2)Take New Video 3)Existing Image/Video
过程会是这样
1)我使用全局变量
2)所以,当一级菜单我的用户点击设置全局变量值1
3)启动活动像下面的结果
Process will be like this 1)I use an global variable 2)So when user click on menu one I sets global variable value to 1 3) Start the activity for result like below
try{
System.gc();
String fileName = System.currentTimeMillis()+".jpg";
String mPathImage = Environment.getExternalStorageDirectory()+ "/" + fileName;
File file = new File(mPathImage);
Uri outputFileUri = Uri.fromFile( file );
Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
mIntent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult(mIntent, 1);
mValue=1;
}赶上(例外五){
}catch(Exception e){
}
如果菜单2在用户点击后我改变全局变量的值设置为2
&安培;开始为结果的活动像下面。
If User click on menu 2 I change value of global variable to 2 & starts the activity for result like below.
try {
System.gc();
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, 1);
mValue=2;
}catch(Exception e){}
如果第三个菜单在用户点击我设置值3
&安培;开始为结果的活动像下面。
If user click on 3rd menu I set value to 3 & start the activity for result like below.
try{
System.gc();
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
startActivityForResult(intent,1);
mValue=3;
}catch(Exception e){}
}
这将显示所有图片及视频的移动
This will show all the images & video's in mobile
后来终于当活动被关闭使用全局变量来检查用户是否需要新的图像或视频或现有的图像/视频。
Then finally when activity gets closed use global variable to check whether user want to new image or video or existing image/video.
希望这会帮助你。
这篇关于Android相机的图片和视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!