原标题:Android app自动更新总结(已适配9.0)
1.配置:1.1 AndroidManifest.xml中添加权限和FileProvider:
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
android:name="androidx.core.content.FileProvider"
android:authorities="com.fengzhi.wuyemanagement.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
1.2 新建文件(路径:resxmlfile_paths.xml):
1.3 (app的)build.gradle:
implementation "com.lzy.net:okgo:3.0.4"//okgo 网络请求
implementation 'com.google.code.gson:gson:2.8.2'//gson
implementation "org.permissionsdispatcher:permissionsdispatcher:4.3.1"//权限
annotationProcessor "org.permissionsdispatcher:permissionsdispatcher-processor:4.3.1"//权限
2.这里以点击按钮进行更新为例:2.1 核心代码:
privateintversion;
/* 更新进度条 */
privateProgressBar mProgress;
privateAlertDialog mDownloadDialog;
--------------------------------------------------------------------------------------------------------------------
//点击按钮,检查权限,,,检查更新的方法