Android Question Problem with "startActivityForResult"

JOTHA

Well-Known Member
Licensed User
Longtime User
I have the following problem with "startActivityForResult":

1) I use "startActivityForResult" to take pictures with the camera. That works fine.
2) I would like to copy the images to the external SD card, for this I need "startActivityForResult" again (as in the tutorial "SaveAs").

... and now the problem begins: The error message "java.lang.RuntimeException: Method: StartActivityForResult not found in: anywheresoftware.b4a.BA" appears.

Is that because this method is used twice and it is still used by the camera application and is not released?

The error starts in this line:

B4X:
    jo.RunMethod("StartActivityForResult", Array(ion, i))

Attached is the log file...
modul_83_startactivityforresult (java line: 10048)
java.lang.RuntimeException: Method: StartActivityForResult not found in: anywheresoftware.b4a.BA
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
at jothasoft.de.fivestars.modul_83._startactivityforresult(modul_83.java:10048)
at jothasoft.de.fivestars.modul_83$ResumableSub_SaveAs.resume(modul_83.java:9969)
at jothasoft.de.fivestars.modul_83._saveas(modul_83.java:9911)
at jothasoft.de.fivestars.modul_83$ResumableSub_Button1_Click.resume(modul_83.java:512)
at jothasoft.de.fivestars.modul_83._button1_click(modul_83.java:485)
at jothasoft.de.fivestars.modul_83$ResumableSub_TakePicture.resume(modul_83.java:10588)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:207)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4j.object.JavaObject$1.invoke(JavaObject.java:238)
at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at $Proxy2.ResultArrived(Unknown Source)
at anywheresoftware.b4a.BA$4.run(BA.java:585)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:459)
at jothasoft.de.fivestars.main$ResumeMessage.run(main.java:313)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7893)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
modul_83_startactivityforresult (java line: 10048)
java.lang.RuntimeException: Method: StartActivityForResult not found in: anywheresoftware.b4a.BA
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
at jothasoft.de.fivestars.modul_83._startactivityforresult(modul_83.java:10048)
at jothasoft.de.fivestars.modul_83$ResumableSub_SaveAs.resume(modul_83.java:9969)
at jothasoft.de.fivestars.modul_83._saveas(modul_83.java:9911)
at jothasoft.de.fivestars.modul_83$ResumableSub_Button1_Click.resume(modul_83.java:512)
at jothasoft.de.fivestars.modul_83._button1_click(modul_83.java:485)
at jothasoft.de.fivestars.modul_83$ResumableSub_TakePicture.resume(modul_83.java:10588)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:207)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4j.object.JavaObject$1.invoke(JavaObject.java:238)
at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at $Proxy2.ResultArrived(Unknown Source)
at anywheresoftware.b4a.BA$4.run(BA.java:585)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:459)
at jothasoft.de.fivestars.main$ResumeMessage.run(main.java:313)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:207)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4j.object.JavaObject$1.invoke(JavaObject.java:238)
at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
at $Proxy2.ResultArrived(Unknown Source)
at anywheresoftware.b4a.BA$4.run(BA.java:585)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:459)
at jothasoft.de.fivestars.main$ResumeMessage.run(main.java:313)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7893)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
 
Last edited:

walterf25

Expert
Licensed User
Longtime User
I have the following problem with "startActivityForResult":

1) I use "startActivityForResult" to take pictures with the camera. That works fine.
2) I would like to copy the images to the external SD card, for this I need "startActivityForResult" again (as in the tutorial "SaveAs").

... and now the problem begins: The error message "java.lang.RuntimeException: Method: StartActivityForResult not found in: anywheresoftware.b4a.BA" appears.

Is that because this method is used twice and it is still used by the camera application and is not released?

The error starts in this line:

B4X:
    jo.RunMethod("StartActivityForResult", Array(ion, i))

Attached is the log file...
Where are these two functions defined?

B4X:
Sub StartActivityForResult(i As Intent)
    Dim jo As JavaObject = GetBA
    ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
    jo.RunMethod("startActivityForResult", Array(ion, i))
End Sub

Sub GetBA As Object
    Dim jo As JavaObject = Me
    Return jo.RunMethod("getBA", Null)
End Sub

They have to be in each activity you are calling it from.

Walter
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I have the following problem with "startActivityForResult":

1) I use "startActivityForResult" to take pictures with the camera. That works fine.
2) I would like to copy the images to the external SD card, for this I need "startActivityForResult" again (as in the tutorial "SaveAs").

... and now the problem begins: The error message "java.lang.RuntimeException: Method: StartActivityForResult not found in: anywheresoftware.b4a.BA" appears.

Is that because this method is used twice and it is still used by the camera application and is not released?

The error starts in this line:

B4X:
    jo.RunMethod("StartActivityForResult", Array(ion, i))

Attached is the log file...
Fyi, startActivityForResult & the associated onActivityResult are deprecated. You should use an ActivityResultContract instead - although I don't know how this is implemented in B4A.

Also, Java is case sensitive so I think your call should be "startActivityForResult", not "StartActivityForResult".

- Colin.
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
startActivityForResult & the associated onActivityResult are deprecated
Thank you for your hint.
I know that, but there is no other way to a solution ... ?

They have to be in each activity you are calling it from.
Thank you for your answer.
Yes, but they are on the same page. I use B4xPages-
I found a way: I use the code on another page and then i call it from the other page (this works) :)

Try this, I hope it works for you.
Thank you very much - Yes, it works!

Is it possible to "Click Save" by code?
I think the answer is "No" - because it is an Intent-Call?

-------------------------------------------------------------

The reason for my question is as follows:

I have an app that I use to take photos. These are automatically labeled and numbered and copied to a specific folder. This folder is created automatically beforehand. This all works in the internal folder.

Now I want it to be checked whether there is an SD card in the smartphone and if so, then this folder with all its content (PDF, TXT and JPG) should be automatically copied to the SD card.
 
Upvote 0
Top