ACTION_INSTALL_PACKAGE

Meine App versucht, ein APK zu installieren.

Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
installIntent.setData(Uri.fromFile(new File(pathToApk)));
installIntent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
installIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
((Activity)context).startActivityForResult(installIntent, Constants.APP_INSTALL_REQUEST);

In meiner Aktivität

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
        case Constants.APP_INSTALL_REQUEST:
            if(resultCode == RESULT_OK){
                Log.e(TAG, "Package Installation Success");
            }else if(resultCode == RESULT_FIRST_USER){
                Log.e(TAG, "Package Installation Cancelled by USER");
            }else{
                Log.e(TAG, "Something went wrong - INSTALLATION FAILED");
            }

Wenn mein startActivityResult ausgelöst wird, erhält meine Aktivität sofort den Ergebniscode 0, der RESULT_CANCELLED entspricht, während die Benutzeroberfläche für die Systeminstallation noch auf die Benutzerberechtigung wartet.

Meine Tätigkeit, um tatsächlich zu erfahren, ob die Installation erfolgreich war oder nicht und basierend auf diesem Update seine Benutzeroberfläche.

Jede Hilfe wäre willkommen.

Antworten auf die Frage(1)

Ihre Antwort auf die Frage