hi all,
i wnat to take picture with camera application. i check in android 4.7 when camera is opened, application will be closed.
and it gives me an error about my codes that is in the Activity Create. but i don't have any problems and errors on the other phone. what should i do?
i wnat to take picture with camera application. i check in android 4.7 when camera is opened, application will be closed.
and it gives me an error about my codes that is in the Activity Create. but i don't have any problems and errors on the other phone. what should i do?
B4X:
Dim i As Intent
i.Initialize("android.media.action.IMAGE_CAPTURE", "")
File.Delete(Starter.provider.SharedFolder, "tempimage.jpg")
i.PutExtra("output",Starter.provider.GetFileUri("tempimage.jpg"))
Try
StartActivityForResult(i)
Catch
imgortxt(True,l2,img,txt,BTN_Cam,BTN_Mic)
Codes.ToastMessageShows("unsupported.",True)
Log(LastException)
End Try
Wait For Camera_result (Args() As Object)
If -1 = Args(0) Then
Try
CropImageView1.ImageBitmap = Null
Dim in As Intent = Args(1)
Dim l2 As Map = List.Get(((Page-1)*tedadSoulperpage)+position)
Dim bitmap As Bitmap
If File.Exists(Starter.provider.SharedFolder, "tempimage.jpg") Then
bitmap = LoadBitmapSample(Starter.provider.SharedFolder, "tempimage.jpg", ImageView1.Width, ImageView1.Height)
Else If in.HasExtra("data") Then
Dim jo As JavaObject = in
bitmap = jo.RunMethodJO("getExtras", Null).RunMethod("get", Array("data"))
End If
If bitmap.IsInitialized = True Then
PNL_Zoom.SetVisibleAnimated(500,False)
PNL_Crop.SetVisibleAnimated(500,True)
If bitmap.Height>bitmap.Width Then
CropImageView1.ImageBitmap = bitmap.Resize((850dip*bitmap.Width)/bitmap.Height,850dip,True)
Else
CropImageView1.ImageBitmap = bitmap.Resize(850dip,(850dip*bitmap.Height)/bitmap.Width,True)
End If
CropImageView1.Tag = l2.Get("ID")
Else
imgortxt(True,l2,img,txt,BTN_Cam,BTN_Mic)
Codes.ToastMessageShows("Error",False)
End If
Catch
imgortxt(True,l2,img,txt,BTN_Cam,BTN_Mic)
Codes.ToastMessageShows("Error",False)
Log(LastException)
End Try
End If
Sub ion_Event (MethodName As String, Args() As Object) As Object
CallSubDelayed2(Me,"Camera_result",Args)
Return Null
End Sub
Sub StartActivityForResult(i As Intent)
Try
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
Catch
Log(LastException)
End Try
End Sub
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