Hi all.
later many time the google made a new documentation, clear and more easy about how use the camera.
on this link u will see intent codes and one example.
https://developer.android.com/training/camera/photobasics.html
i m trying compile this intents for b4a
i m with a problem on the get thumbnail
i m using StartActivityForResult to call the camera intent take picture and later get the result (path) where is the file.
the first simple result its a thumbnail, like show on google example i made this.
Google Example
What i made
the logs is
where is the problem here?
Like on the description
i m trying convert this i.GetExtra("data") to bitmap but dont works.
i m tryied open a InputStream and i have the same problem.
what is the error here?
like show on the logs the image (thumbnail) its saved with path
content://media/external/images/media/513
but if i try load this put into a bitmap i got the same error.
ps: i m already tryed add .jpg and the error continue.
ps2: if i use Log(i.ExtrasToString) this show
Bundle[{data=android.graphics.Bitmap@f2a52b1, bitmap-data=true}]
the bitmaps is here, now i need know how take this
thx
later many time the google made a new documentation, clear and more easy about how use the camera.
on this link u will see intent codes and one example.
https://developer.android.com/training/camera/photobasics.html
i m trying compile this intents for b4a
i m with a problem on the get thumbnail
i m using StartActivityForResult to call the camera intent take picture and later get the result (path) where is the file.
the first simple result its a thumbnail, like show on google example i made this.
Google Example
B4X:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
mImageView.setImageBitmap(imageBitmap);
}
}
What i made
B4X:
Sub ion_Event (MethodName As String, Args() As Object) As Object
If Args(0) = -1 Then ' = RESULT_OK
Dim i As Intent = Args(1)
Log(Args(1))
Log(i.HasExtra("data"))
Log(i.GetExtra("data"))
Private filename As String = i.GetData.SubString(i.GetData.LastIndexOf("/") + 1)
Private dir As String = i.GetData.SubString2(0,i.GetData.Length - filename.Length)
Log(filename)
Log(dir)
Private bm As Bitmap '= i.GetExtra("data")
Dim input As InputStream = File.OpenInput(dir, filename)
bm.Initialize2(input)
input.Close
ImageView1.Bitmap = bm
End If
Return Null
End Sub
the logs is
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
Intent { act=inline-data dat=content://media/external/images/media/513 flg=0x1 (has extras) }
true
null
513
content://media/external/images/media/
Error occurred on line: 48 (Main)
java.io.FileNotFoundException: content:/media/external/images/media/513: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209)
at b4a.example.main._ion_event(main.java:511)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4j.object.JavaObject$1.invoke(JavaObject.java:237)
at java.lang.reflect.Proxy.invoke(Proxy.java:397)
at $Proxy0.ResultArrived(Unknown Source)
at anywheresoftware.b4a.BA$4.run(BA.java:513)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:398)
at b4a.example.main$ResumeMessage.run(main.java:296)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6946)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 26 more
** Activity (main) Resume **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
where is the problem here?
Like on the description
The Android Camera application encodes the photo in the return Intent delivered to onActivityResult() as a small Bitmap in the extras, under the key"data". The following code retrieves this image and displays it in an ImageView.
i m trying convert this i.GetExtra("data") to bitmap but dont works.
i m tryied open a InputStream and i have the same problem.
what is the error here?
like show on the logs the image (thumbnail) its saved with path
content://media/external/images/media/513
but if i try load this put into a bitmap i got the same error.
ps: i m already tryed add .jpg and the error continue.
ps2: if i use Log(i.ExtrasToString) this show
Bundle[{data=android.graphics.Bitmap@f2a52b1, bitmap-data=true}]
the bitmaps is here, now i need know how take this
thx
Last edited: