Android Question Camera intent works in Debug Mode only.

Hilton

Active Member
Licensed User
Longtime User
Hi All,

Running b4a v6.50 Android 4.4.2 on Huawei phone.

Debug Mode:
I can take photos, store them, write details to sqlite,associate notes with each picture, flip thru them (prev next) and delete them.
Works very well!

Release Mode:
Complains that the intent in ion_Event is not initialised and therefore does nothing.

(RuntimeException) java.lang.RuntimeException: Object should first be initialized (Intent).

B4X:
'result arrives here
Sub ion_Event (MethodName As String, Args() As Object) As Object
    If Args(0) = -1 Then
        Try
            Dim in As Intent = Args(1)
            Log("args1:" & Args(1))                                     <-------is null??
            If File.Exists(imageFolder, tempImagefile) Then
                lastPicture = LoadBitmapSample(imageFolder, tempImagefile, imageView1.Width, imageView1.Height)
                savePic
                imageView1.Bitmap = lastPicture
                myNote.setNote("")
            Else If in.HasExtra("data") Then 'try to get thumbnail instead
                Dim jo As JavaObject = in
                lastPicture = jo.RunMethodJO("getExtras", Null).RunMethod("get", Array("data"))
            End If
        Catch
            Log(LastException)
        End Try
    End If
    If lastPicture.IsInitialized Then imageView1.Bitmap = lastPicture
    Return Null
End Sub

Any ideas?

Thanks,
Hilton.
 

Hilton

Active Member
Licensed User
Longtime User
It is better to post the exact message from the logs.

1. Is ion a process global variable?
2. Why aren't you using ContentChooser?

Hi Folks,
Thanks for the response Erel, in response:
1. the error message was copied from the logs
2. Yes a global variable
3. Not relevant, I use the stored location in sqlite db to retrieve pictures for a specific job.

After much fiddling around, I found that if I used
File.DirRootExternal plus the rest of the path
instead of
Starter.rp.GetSafeDirDefaultExternal("")
then all was fine.

The problem seemed to be a Access Error.

Then I confused myself by reverting to my original code using starter.rp.GetSafeDirDefaultExternal("")
just to double check that I was not going to waste anyone's time - and it now works fine.

Perhaps it was a phone problem, in any event I apologize for wasting any of your time.

Hilton.
 
Upvote 0

Hilton

Active Member
Licensed User
Longtime User
Hi All,

After confusing myself, I can now categorically state that if I use File.DirRootExternal, the program works.
If I use Starter.rp.GetSafeDirDefaultExternal("") it fails(something to do with access denied).

I add this just in case someone else has a similar problem.
 
Upvote 0
Top