Android Tutorial Intent Based Camera

Status
Not open for further replies.
Newer example: [B4X] [B4XPages] Intent based camera

This example uses an intent to take a picture with the default camera app.

It is based on this tutorial: https://developer.android.com/training/camera/photobasics.html

It is simple to use and doesn't require any permission (*).

It does rely on the default camera app to work properly and save the image file in the path passed in the intent.
As a fallback, if the image was not saved it tries to get the thumbnail from the intent returned.

Don't miss the manifest editor code that is required for sharing file uris.
 

Attachments

  • CameraIntent.zip
    9.5 KB · Views: 2,743
Last edited:

jayel

Active Member
Licensed User
Longtime User
hey,

Image is turned 90 degrees? How can I show in the right way?
 

uniplan

Active Member
Licensed User
Longtime User
Is possibile add an editbox into the form where are "OK" and "Cancel" buttons ?
 

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Guys

This code triggers an exception when used from within a class module

B4X:
Sub GetBA As Object
   Dim jo As JavaObject
   Dim cls As String = Me
   cls = cls.SubString("class ".Length)
   jo.InitializeStatic(cls)
   Return jo.GetField("processBA")
End Sub

The same code works fine if moved to parent activity.

Is there a workaround?

Thanks in advance
 

yiankos1

Well-Known Member
Licensed User
Longtime User
Good morning,
When i take photo and returns to main app, app starts at landscape and immediately changes to portrait. I want to use this at my app, but this behavior is not professional.
Thank you for your time.

p.s. tried on Galaxy S4
 

Pooya1

Active Member
Licensed User
Can i use this code in all android version without problem? (i would like make without any library for take picture from camera)
Problems like "cannot connect to camera","cannot save output" or any problem that it is dangerous
 

Marcos Alves

Well-Known Member
Licensed User
Longtime User
This example uses an intent to take a picture with the default camera app.

It is based on this tutorial: https://developer.android.com/training/camera/photobasics.html

It is simple to use and doesn't require any permission (*).

It does rely on the default camera app to work properly and save the image file in the path passed in the intent.
As a fallback, if the image was not saved it tries to get the thumbnail from the intent returned.

* - It uses RuntimePermissions.GetSafeDirDefaultExternal which means that you need to add the external storage permission to older versions of Android with this manifest code:
B4X:
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="18" />
)

Is there any way to receive video from camera also?
 
D

Deleted member 103

Guest
Hi,

I have changed the example of Erel so that the photos can now be saved under the default order "../DCIM/Camera".
 

Attachments

  • CameraIntent.zip
    9.1 KB · Views: 546

winiha

Member
Licensed User
Hi,

I have changed the example of Erel so that the photos can now be saved under the default order "../DCIM/Camera".
it dose not work for me. (android 7.0)

how can change Erel's code such that taken picture directly save in File.DirRootExternal (for example, or in specific directory).
in the other word manifest be only write external storage and camera permission not default path.
 
Last edited:
D

Deleted member 103

Guest
it dose not work for me. (android 7.0)

how can change Erel's code such that taken picture directly save in File.DirRootExternal.
in the other word manifest is only write external storage permission not default path.
You just have to change the "/DCIM/Camera" folder to your folder.
 
Status
Not open for further replies.
Top