I can run Erel's example just fine, but when I integrate it in my app, I get a java.lang.RuntimeException: Object should first be initialized (Cursor). error
I have attached a minimized version of my app with just the offending code. It picks an image from the chooser and scales it to best fit the screen.
Here is the entire error message:
and here is the line of code that causes the error:
Note that my app will give you an error first because it cannot find a picture it's supposed to load but that I had to take out because the zip file was too big.
Once the app is running, click on "Pick new map" in the menu and select an image. The app crashes when the image is selected and the chooser closes.
The code in this post is now fixed: http://www.b4x.com/android/forum/threads/using-photos-from-the-phone.37444/#post-221367
I've also uploaded a simple example.
I have attached a minimized version of my app with just the offending code. It picks an image from the chooser and scales it to best fit the screen.
Here is the entire error message:
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
Error occurred on line: 101 (Main)
java.lang.RuntimeException: Object should first be initialized (Cursor).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.sql.SQL$CursorWrapper.setPosition(SQL.java:322)
at b4a.example.main._getpathfromcontentresult(main.java:649)
at b4a.example.main._cc_result(main.java:571)
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:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.phone.Phone$ContentChooser$1.ResultArrived(Phone.java:843)
at anywheresoftware.b4a.BA$4.run(BA.java:547)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:432)
at b4a.example.main$ResumeMessage.run(main.java:301)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
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:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
** Activity (main) Resume **
and here is the line of code that causes the error:
B4X:
Cursor1.Position = 0
Note that my app will give you an error first because it cannot find a picture it's supposed to load but that I had to take out because the zip file was too big.
Once the app is running, click on "Pick new map" in the menu and select an image. The app crashes when the image is selected and the chooser closes.