I want to launch Android built-in camera app with a thumbnail icon on the right-bottom. Here is my code to open the camera app.
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
I think I need to put a intent data to do it. I look forward to your help.
Thanks.
Just create an image button, or button or anything you desire really.
In the onclick event add something like:
String saveFileName= Environment.getExternalStorageDirectory() + "/test.png";
// BUILT IN CAMERA
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
camera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(saveFileName) );
this.startActivityForResult(camera, 1);
Make sure you have necessary permissions set. Like saving to the SDCard.
You are very close, you dont need those flags set. And you should ideally specify where you are saving the image.
If you are wondering how to make the button take a look here
Related
I am implementing an android app, which will synchronize images from selected folder to server (as Google Photo). I want that user will select folder by clicking on button. I can achieve this by creating my own view. But, if implicit intent can any implicit intent action by which I can show user only images folder from device?
Try,
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 100);
change EXTERNAL_CONTENT_URI constant accordingly.
I am working with camera in project and provided a simple button in activity which will open camera app in my device. But the problem is after clicking one photo, it asks weather I want to keep my picture or not and after clicking yes, it return to my main activity.
But I want to operate camera in normal mode, I mean like when we click photo after photos and all that.
My code
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, 0);
following permission is used
uses-permission android:name="android.permission.CAMERA" uses-permission
I dont know why tags are not working.
Any kind of help is appreciated!
To take multiple photos, you should launch the intent with this action:
Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
startActivity(intent);
i am creating an application.
and use device default camera to take picture.
using this
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, CAMERA_PICTURE);
in onActivityResult() method i call again above code and take picture again.
but i want to take multiple pictures at a time. is there any way to take picture automatically when camera is called by intent (not by creating custom camera activity).
By sending intent you just say to existing camera application that it start and allow user to take picture - you are completely on the mercy of this application. Some of them may contain some undocumented parameters allowing you to snap picture automcatically.
http://developer.android.com/guide/topics/media/camera.html#intent-image
If you like to have control, you shall code camera application yourself.
I suppose you have to write your own custom camera, as there is no extra in MediaStore class that would allow taking another picutre.
Assuming I know that the Gallery has an album with a certain name X, what intent or broadcast can I make to open Album X with the Gallery app?
There are plenty of examples showing how to select a picture from the Gallery, but I don't see any describing how to accomplish the above.
Thanks.
try this
Intent intent = new Intent();
intent.setType("image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Main.this.startActivity(intent);
program will browser all application are support with image file
but user can set default program
If you prepared the Gallery which is called X, yes you can do it.
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.Xapp");
if (launchIntent != null) {
launchIntent.setData("PHOTO ID OR ANYTHING ELSE");
startActivity(launchIntent);
}
After then you can set data in intent. And X app parses intent data and you can open it.
Otherwise, you can't this action. You only call the app, If the application does not provide API support for send data with intent.
I use the Android camera Intent to take a picture.
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
this.startActivityForResult(intent, GalleryActivity.PHOTO_ACTIVITY);
Is there any way to disallow the user to retake the picture and immediately get back to the calling Activity, even without having to press the OK button to accept the image? (I don't wanna have to reimplement the camera activity already provided).
Not by using an Intent to capture the photo.
You'll need to use Androids Camera-Classes.