Question

I'm using startActivityForResult / onActivityResult to communicate between two apps on Google Glass.

Calling code:

Intent intentScan = new Intent("com.github.barcodeeye.SCAN");
intentScan.setPackage("com.github.barcodeeye");
intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intentScan.putExtra("SCAN_MODE", "QR_CODE_MODE");
intentScan.putExtra("RESULT_DISPLAY_DURATION_MS", 1000L);
intentScan.putExtra("SAVE_HISTORY", false);
intentScan.putExtra("PROMPT_MESSAGE", "Scan MQTT Config Code");

startActivityForResult(intentScan, 333);

Response code:

    activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
    activity.finish();

onActivityResult

    if (requestCode == 333 && resultCode == RESULT_OK)
        processQRCode(data);

I debugged through both apps, the called app gets to setResult and finish, but onActivityResult is never called

What can cause this?

(I'm calling a fork of the BarcodeEye project that re-enables the ability to call it through intents: https://github.com/paulpv/BarcodeEye/tree/intent)

Was it helpful?

Solution

As with the vast majority of similar questions about returning content across activities on SO, the issue was with my code. I was calling from inside a menu activity, and was calling finish() right after the startActivityForResult() call. Clearly, that meant no one was listening when the response came back.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top