Ok, so here is the situation: I am working with a keyboard (https://github.com/AnySoftKeyboard/AnySoftKeyboard) and a barcode scanner (https://github.com/dm77/barcodescanner). When I press a specific button on the keyboard, it opens the barcode scanner, after it scans, it returns to the previous screen (let's say messaging app) with the result. All fine and dandy, except for the fact that I can't insert the result in the EditText, because the input connection "getCurrentInputConnection()" is different from the initial one (before launching the barcode scanner activity), because it's another instance (this happens because I launch a barcode scanner activity and after I'm returning to the initial screen (messaging app with the keyboard shown and the EditText focused). Here is the code for inserting in any EditText from any app:
InputConnection inputConnection = getCurrentInputConnection();
inputConnection.setComposingText(scanResult, 1);
Any ideas on how to solve this ?