android-camera-intent

Camera Intent Returns Null

对着背影说爱祢 提交于 2019-12-04 18:22:43
I am trying to capture image and video from my android application with the default camera using Intent. Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, IMAGE_FROM_CAMERA); Using above code i tried to capture Image and in onActivityResult i am getting Null in the data at data.getData() I tried with passing the Uri with the intent but the Uri gets Empty. Camera intent is not able to write image on the uri. I need the uri to send image video with Email. Error Log 07-26 21:16:54.125: E/AndroidRuntime(6142): java.lang.RuntimeException: Failure

Android: How to save the camera result to a private file

流过昼夜 提交于 2019-12-04 11:34:16
问题 I am trying to get an image from the camera and save it directly to my app's private files directory. For security concerns, the image should not be publicly accessible at any time. In general, the way you grant temporary access to a private file is to use a ContentProvider and set the GRANT_WRITE_URI_PERMISSION flag in the Intent. Following the documentation in FileProvider, I have done the following: AndroidManfiest.xml <manifest> ... <application> ... <provider android:authorities="com.my

Using camera to take photo and save to gallery

假装没事ソ 提交于 2019-12-04 11:05:18
I have went through several documentation and stacks, however I'm not quite sure how do I implement this... And help or sample codes would really help me understand more. Here are the sets of codes that runs the camera and it's working perfectly fine, my next question is, how do I let it automatically saved into phone gallery? @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); tvCameraTiles = (TextView) findViewById(R.id.tvCameraTiles); tvCameraTiles.setOnClickListener(new View.OnClickListener() { @Override

android picture from camera being taken at a really small size

天涯浪子 提交于 2019-12-04 08:55:46
Im trying to capture an image from the camera, compress it, then store it to the SD card. If I directly save it to the SD card using the code directly below, I get the full image. But if i try and load the image in the system, i get a super small image size such as 320 by 240 instead of a full 5 mp image. Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri()); startActivityForResult(intent, CAMERA_PIC_REQUEST); where getImageURI() is private Uri getImageUri() { // Store image in dcim file = new File(Environment

lock your camera view to landscape mode in android [duplicate]

蓝咒 提交于 2019-12-04 08:03:04
This question already has an answer here: How to lock the orientation to Portrait when using intent ACTION_IMAGE_CAPTURE? 1 answer I want to lock my camera view to " Landscape " mode.When I click on the simple button in my app, that time device's camera will open and and that camera should be locked to " Landscape mode ". Can anyone know the solution of this problem? I am using this code inside "CaptureImageActivity.java" activity. So after execution of this activity my system's camera will open. btn1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i

android camera and gallery not working in nexus 5

ぃ、小莉子 提交于 2019-12-03 21:58:11
In my application I use camera and gallery to upload the selected image to server. it's working fine till 4.4.2, but in 4.4.4 nexus5 both camera and gallery don't work. my camera part is in a Fragment .If I try to take a photo using the camera or pick a photo using the gallery I get "please retry" message as per my code. camera action code: String path = Environment.getExternalStorageDirectory() + "/appname"; File photopath = new File(path); if (!photopath.exists()) { photopath.mkdir(); } try { Intent captureIntent = new Intent( MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult

Camera intent android

北战南征 提交于 2019-12-03 21:40:00
When I begin the camera intent I give it a file name I would like it to use. When I get this on the phone it uses the phones default file name. Which is no help as I need the image name later in the app. Camera intent code... public void onClick(View view) { String currentDateTimeString = DateFormat.getDateInstance().format(new Date()); System.out.println(currentDateTimeString); filename = ("/sdcard/" + currentDateTimeString + ".jpg"); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(Environment.getExternalStorageDirectory(), filename); outputFileUri = Uri

What's the difference between ActivityCompat and ContextCompat?

给你一囗甜甜゛ 提交于 2019-12-03 10:10:01
I'm trying to use the Android camera, for API 23 or above, it requires asking for permission at runtime. According to the documentation , I can accomplish that using, ActivityCompat or ContextCompat. I don't understand what are the difference between the two and their trade-offs. Thank you for time. I don't understand what are the difference between the two and their trade-offs There's no trade-off really. Not sure why they wrote so - checkSelfPermission() is a method of ContextCompat and ActivityCompat is subclass (child) of ContextCompat so you can pass either one whenever object of

Android Camera intent creating two files

家住魔仙堡 提交于 2019-12-03 10:09:00
问题 I am making a program that takes a picture and then shows it's thumbnail. When using the emulator all goes well and the discard button deletes the photo. But on a real device the camera intent saves the image at the imageUri variable and a second one that is named like if I had just opened up the camera and took a picture by itself. private static final int CAMERA_PIC_REQUEST = 1337; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) {

Capture Image while Device is Locked with Password

 ̄綄美尐妖づ 提交于 2019-12-03 06:06:54
问题 I want to implement a functionality to capture image through front camera when someone tries to unlock my device and enter incorrect password 3 times. I checked that it is possible in Android and some applications are also available in Market. I have done some work to achieve this but I am getting a black Image. Here's the code : Register with Device admin to get the broadcast for incorrect password attempt : public class DeviceAdminSample extends DeviceAdminReceiver { static Context ctx;