In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the Android8.0 version update can not automatically install how to solve the relevant knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that after reading this Android8.0 version update can not automatically install how to solve the article will have a harvest, let's take a look.
Realize
1. Manifest file permission statement
two。 Click install to determine whether you have permission.
If (Build.VERSION.SDK_INT > = 26) {/ / to determine whether the application has permission to install apk boolean installAllowed= getPackageManager () .canRequestPackageInstalls (); / / has permission to install if (installAllowed) {/ / install apk install (apkPath);} else {/ / does not have permission to apply for permission ActivityCompat.requestPermissions (this, new String [] {Manifest.permission.REQUEST_INSTALL_PACKAGES}, INSTALL_APK_REQUESTCODE) }} else {install (apkPath);}
Permission request callback
@ Override public void onRequestPermissionsResult (int requestCode, @ NonNull String [] permissions, @ NonNull int [] grantResults) {super.onRequestPermissionsResult (requestCode, permissions, grantResults); switch (requestCode) {case INSTALL_APK_REQUESTCODE: / / has registration permission and the user is allowed to install if (grantResults.length > 0 & & grantResults [0] = = PackageManager.PERMISSION_GRANTED) {install (apkPath) } else {/ / directs the user to install an unknown application interface. Intent intent = new Intent (Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES); startActivityForResult (intent, GET_UNKNOWN_APP_SOURCES);} break;}}
Install APK
Private void install (String apkPath) {/ / 7.0 via FileProvider if (Environment.SYSTEM_VERSION_CODE > = 24) {Uri uri = FileProvider.getUriForFile (context, Environment.FILE_PROVIDER_AUTHORITY, new File (apkPath)); Intent intent = new Intent (Intent.ACTION_VIEW) .setDataAndType (uri, "application/vnd.android.package-archive"); intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK) Intent.addFlags (Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity (intent);} else {Intent intent = new Intent (Intent.ACTION_VIEW); intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType (Uri.parse ("file://" + apkPath)," application/vnd.android.package-archive "); context.startActivity (intent) }} this is the end of the article on "how to solve the problem that Android8.0 version updates cannot be installed automatically". Thank you for reading! I believe you all have a certain understanding of the knowledge of "Android8.0 version update can not be automatically installed". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.