This commit is contained in:
Jerry Yan 2020-02-27 21:32:49 +08:00
parent 60760914f6
commit 282da3e706
3 changed files with 9 additions and 5 deletions

View File

@ -10,8 +10,8 @@
</intent-filter> </intent-filter>
</receiver> </receiver>
<provider <provider
android:name="android.support.v4.content.FileProvider" android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider" android:authorities=".J_FileProvider"
android:grantUriPermissions="true" android:grantUriPermissions="true"
android:exported="false"> android:exported="false">
<!-- 元数据 --> <!-- 元数据 -->

View File

@ -8,7 +8,6 @@ import android.content.SharedPreferences;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.util.Log;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
@ -39,9 +38,8 @@ public class DownLoadBroadcastReceiver extends BroadcastReceiver {
} }
if(filePath == null) return; if(filePath == null) return;
File file = new File(filePath); File file = new File(filePath);
Log.e("PATH", String.valueOf(Uri.fromFile(file)));
if (Build.VERSION.SDK_INT >= 24) { if (Build.VERSION.SDK_INT >= 24) {
Uri apkUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + "" + ".fileprovider", file); Uri apkUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID.concat(".J_FileProvider"), file);
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
install.setDataAndType(apkUri, "application/vnd.android.package-archive"); install.setDataAndType(apkUri, "application/vnd.android.package-archive");
} else { } else {

View File

@ -0,0 +1,6 @@
package top.jerryyan.RN.A.VersionUpgrade;
import androidx.core.content.FileProvider;
public class J_FileProvider extends FileProvider {
}