vendredi 20 mars 2015

How to get onActivityResult called from ACTION_VIEW intent


I have an app that needs to install another .apk but I need to catch if the user chooses 'cancel' on the popup that android provides: Here is the method that is called.



private void installNewAgent(String agentName) {

Intent launchAgent = new Intent(Intent.ACTION_VIEW);
launchAgent.setDataAndType(Uri.fromFile(new File(getTempFolderPath() + agentName)), "application/vnd.android.package-archive");
logger.error("[PAUL LOG] parent is: %s", getParent());
getParent().startActivityForResult(launchAgent, INSTALL_REQUEST);
}


the log tells me that the parent is EnrollmentKickoffActivity so in the EnrollmentKickoffActivity.java (which extends Activity) file I put



@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.e("PAUL TEST","requestCode: "+ requestCode + "resultCode: " + resultCode + "data: " + data);
logger.error("[PAUL LOG] resultCode is: %s", resultCode);
super.onActivityResult(requestCode, resultCode, data);
}


but neither of the logs are ever printed. Any ideas as to why it is not being called.





Aucun commentaire:

Enregistrer un commentaire