Home > Mobile >  Android7.0 above and start the installation apk problem, a great god genuflect is begged!
Android7.0 above and start the installation apk problem, a great god genuflect is begged!

Time:09-26

Start to install apk had a lot of online, but I'm a little depressed, this problem was I have start the installation code, and on the same equipment has run up, however, another app using the same code but can't, not much said, the code is as follows:
Already run each part code:
Within the app file
Dependencies {
Implementation fileTree (dir: 'libs', include: [' *. Jar'])
Implementation 'androidx. Appcompat: appcompat: 1.0.2'
Implementation 'androidx. Constraintlayout: constraintlayout: 1.1.3'
TestImplementation 'junit: junit: 4.12'
AndroidTestImplementation 'androidx. Test. Ext: junit: 1.1.0'
AndroidTestImplementation 'androidx. Test. Espresso: espresso - core: 3.1.1'

Implementation files (' libs/waterlibrary - debug. Aar)
}

Androidmanifest.xml
 & lt; The provider 
The android: name="androidx. Core. Content. FileProvider"
Android: authorities="${applicationId}. Fileprovider"
Android: grantUriPermissions="true"
Android: exported="false" & gt;

<meta - data
The android: name="android. Support. FILE_PROVIDER_PATHS"
Android: resource="@ XML/file_paths"/& gt;

, of course, also add the permissions
 & lt; USES - the permission of the android: name="android. Permission. WRITE_EXTERNAL_STORAGE"/& gt; 


XML/file_paths code inside the
 & lt; ? The XML version="1.0" encoding="utf-8"?> 




Start the installation code
 File mfile=new File (path); 
Intent install=new Intent ();
Install. AddFlags (Intent. FLAG_ACTIVITY_NEW_TASK);
The setAction (Intent. ACTION_VIEW);
If (Build) VERSION) SDK_INT & gt;=Build. VERSION_CODES. N) {
//is the android version 7.0 and above
Uri apkUri=FileProvider. GetUriForFile (context, pageNameString + ". FileProvider ", mfile);
Install. AddFlags (Intent. FLAG_GRANT_READ_URI_PERMISSION);//without this sentence, "occurs on the installation parsing packet error prompt, actual Intent is do not have permission to read the file, then is the preliminary to the permissions (because it is not in the main thread execute)
The setDataAndType (apkUri, "application/VND. Android. Package - archive");
} else {
//is under the android 7.0 version//
Install. SetDataAndType (Uri) fromFile (mfile), "application/VND. Android. Package - archive");
}
The context. StartActivity (install);

The above has been to run code
In another app, I found that after contrast may be IDE the upgrade I didn't pay attention
Where
The code in this app
Dependencies {
Implementation fileTree (dir: 'libs', include: [' *. Jar'])

Implementation 'com. Android. Support. The constraint, the constraint - layout: 1.1.3'
Implementation 'com. Android. Support: design: 28.0.0'
Implementation 'com. Android. Support: support - annotations: 28.0.0'
Implementation 'android. Arch. Lifecycle: extensions: 1.1.1'
TestImplementation 'junit: junit: 4.12'
AndroidTestImplementation 'com. Android. Support. Test: runner: 1.0.2'
AndroidTestImplementation 'com. Android. Support. Test. Espresso: espresso - core: 3.0.2'

Implementation files (' libs/waterlibrary - debug. Aar)

}

The corresponding AndroidManifest. XML became so
 & lt; The provider 
The android: name="android. Support. The v4. Content. FileProvider"
Android: authorities="${applicationId}. Fileprovider"
Android: grantUriPermissions="true"
Android: exported="false" & gt;

<meta - data
The android: name="android. Support. FILE_PROVIDER_PATHS"
Android: resource="@ XML/file_paths"/& gt;

Main is different here
The android: name="android. Support. The v4. Content. FileProvider"
Before the android: name="androidx. Core. Content. FileProvider"
Originally I want to quote packages are changed, but it doesn't work, without change the references in the app, in AndroidManifest reference, but the app cannot be launched,
So I was depressed, under the current reference, how do we start the apk installation!
Urgent, such as action genuflect is begged!

CodePudding user response:

What is the error message?

CodePudding user response:

reference 1st floor helloworlddm response:
what is the error message?

Compiler installed app errors, it's no problem for me to download file, start the installation package when direct flash back, because I use the simulator is 7 the following version, can't dubug, as the simulator always won't start,
The key is another APP is in normal use, in addition to I said the code is different,

CodePudding user response:

Eager to put into use, I have to upgrade all the references to support the android: name="androidx. Core. Content. FileProvider"
Can normal installation upgrade now
Principle is not clear, however, still need to teach you, after all network example with the android: name="android. Support. The v4. Content. FileProvider"
To learn more, when you use knowledge, you will find you to less!

CodePudding user response:

The building Lord your APP automatically update online download, Android 9.0 write well? I 9.0 version of the mobile phone can't write permissions are dynamic application

CodePudding user response:

reference Ande, 4/f, Wang reply:
the building your APP automatically update online download, Android 9.0 write well? I 9.0 version of the mobile phone can't write permissions are dynamic application after

I can, I use my glory phone test passed, the code is I posted,

CodePudding user response:

reference Ande, 4/f, Wang reply:
the building your APP automatically update online download, Android 9.0 write well? I 9.0 version of the mobile phone can't write permissions are dynamic application after

Did you check the customer phones to access, I just met the customer failed to pass the written and read and write access failure, manually open the permissions is normal,nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related