Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29487

install permission in android

$
0
0

I have a RN app runs in android, now I want to update it, because android8 request developer to request REQUEST_INSTALL_PACKAGES in app, so I write some code to request install permision, but the code doestn't work.It throwes some errors.

error:can not find symbol.
symbol: Function canRequestPackageInstalls()
location: Class PackageManager

error:can not find symbol.
symbol: Variable O
location: Class VERSION_CODES

error:can not find symbol.
symbol: Variable ACTION_MANAGE_UNKNOWN_APP_SOURCES
location: Class Settings

code:

public void checkVesion() {
    boolean haveInstallPermission;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        haveInstallPermission = myActivity.getPackageManager().canRequestPackageInstalls();
        if (!haveInstallPermission) {
            new AlertDialog.Builder(myActivity)
                    .setTitle("tips")
                    .setMessage("tips code")
                    .setNegativeButton("exit", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.cancel();
                            Toast.makeText(myActivity, "ss", Toast.LENGTH_LONG).show();
                            System.exit(0);
                        }
                    })
                    .setPositiveButton("confirm", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                                Uri packageURI = Uri.parse("package:" + myActivity.getPackageName());
                                Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageURI);
                                (myActivity).startActivityForResult(intent, 2);
                                dialog.cancel();
                            }
                        }
                    }).show()
                    .setCanceledOnTouchOutside(false);
        }else{
            downLoadApk();
        }
    } else {
        downLoadApk();
    }
}

buildToolsVersion is 24.0.0, targetSdkVersion is 26.


Viewing all articles
Browse latest Browse all 29487

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>