are you sure the other application calls setResult() ? that's the only way to get data back from startactivityforresult().
also in your Ion_OnActivityResult (RequestCode As Int, ResultCode As Int, Data As Intent, ExtraParams() As Object sub, you should log all those returned values to see if you got anything. as it is, you only test for what you're looking for, but you don't bother to see if there were things returned that you didn't expect.
Thanks for your reply,
I am actually trying to translate this Java code of a working application into B4A, unfortunately I am not very experienced:
[CODE lang="java" title="Java Code from Android Studio"]// MainActivity.java ***************************************************
private void startVideoProcessing() {
JSONObject settings = new JSONObject();
try {
Settings.put("location", "ITA");
Settings.put("servicePath", "https://api.cloud.com/start");
Settings.put("apiKey", "API KEY");
Settings.put("save",true);
settings.put("receiverClass","com.integration.ResultReceiver");
.......
} catch (JSONException e) {
e.printStackTrace();
}
Intent launchIntent = new Intent(Intent.ACTION_VIEW);
launchIntent.setComponent(new ComponentName("com.clientwithopencv", "com.clientwithopencv.activities.MainActivity"));
if (launchIntent != null) {
launchIntent.putExtra("settings", settings.toString());
startActivity(launchIntent);
}
else {
Log.e(TAG, "intent null");
}
}
}
// ResultReceiver.java *******************************************
public class ResultReceiver extends BroadcastReceiver {
private static final String TAG = "ResultReceiver";
private static Map<String, Handler> handlers;
public ResultReceiver() {
handlers = new HashMap<>();
handlers.put(ResultHandler.Result, new ResultHandler());
handlers.put(EventHandler.Event, new EventHandler());
}
@Override
public void onReceive(Context context, Intent intent) {
final PendingResult pendingResult = goAsync();
Task asyncTask = new Task(pendingResult, intent,context);
asyncTask.execute();
}
private static class Task extends AsyncTask<String, Integer, String> {
private final PendingResult pendingResult;
private final Intent intent;
private final Context context;
private Task(PendingResult pendingResult, Intent intent, Context context) {
this.pendingResult = pendingResult;
this.intent = intent;
this.context = context;
}
@Override
protected String doInBackground(String... strings) {
if(intent.getAction() != null)
{
Handler handler = handlers.get(intent.getAction());
String json = intent.getStringExtra(handler.getExtra());
if(json != null)
{
handler.handle(json,context);
return json;
}
}
return "";
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
// Must call finish() so the BroadcastReceiver can be recycled.
pendingResult.finish();
}
}
}[/CODE]
of course then there are the manifest.xlm to configure.
I don't know if that makes it any clearer.
regards.