百度自动更新
http://app.baidu.com/value/sdkservice
百度更新四种方式
- 默认UI(弹窗,一般采用此方式):
BDAutoUpdateSDK.uiUpdateAction(this, new MyUICheckUpdateCallback()); - 静默更新:
BDAutoUpdateSDK.silenceUpdateAction(this); - 百度助手更新:
BDAutoUpdateSDK.asUpdateAction(this, new MyUICheckUpdateCallback()); - 自定义UI更新:
BDAutoUpdateSDK.cpUpdateCheck(this, new MyCPCheckUpdateCallback());
权限
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
依赖
compile files('libs/BDAutoUpdateSDK_20150605_V1.2.0.jar')
混淆
-dontwarn com.baidu.**
-keep class com.baidu.** { *;}
清单文件
<!-- 百度自动更新SDK -->
<!--百度自动更新开始-->
<activity
android:name="com.baidu.autoupdatesdk.ConfirmDialoigActivity"
android:exported="false"
android:theme="@style/bdp_update_dialog_style_fullscreen"/>
<receiver
android:name="com.baidu.autoupdatesdk.receiver.BDBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.baidu.autoupdatesdk.ACTION_NEW_UPDATE"/>
<action android:name="com.baidu.autoupdatesdk.ACTION_DOWNLOAD_COMPLETE"/>
<action android:name="com.baidu.autoupdatesdk.ACTION_NEW_AS"/>
<action android:name="com.baidu.autoupdatesdk.ACTION_AS_DOWNLOAD_COMPLETE"/>
</intent-filter>
</receiver>
<!--百度自动更新结束-->
<meta-data
android:name="BDAPPID"
android:value="你申请的id"/>
<meta-data
android:name="BDAPPKEY"
android:value="你申请的key"/>
360自动更新
http://dev.360.cn/html/zhuanti/sdkup.html
360更新代码
//初始化弹窗
UpdateHelper.getInstance().init(getApplicationContext(), Color.parseColor("#0A93DB"));
//手动点击升级(建议)
UpdateHelper.getInstance().manualUpdate("你的包名");
/*
参数packageName:应用的包名
参数forceUpdate:是否强制更新。当forceUpdate = true时进行强制更新,更新窗口无法被销毁;当forceUpdate = false时不强制更新,更新窗口可以被销毁
参数queryIntervalMillis:弹窗间隔毫秒时间。当第一次出现更新弹窗后,在queryIntervalMillis毫秒内进行第二次函数调用不会查询更新
UpdateHelper.getInstance().autoUpdate(String packageName, final boolean forceUpdate, final long queryIntervalMillis);
*/
//自动升级
UpdateHelper.getInstance().autoUpdate("你的包名", false, 10000);
权限
<uses-permissionandroid:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
依赖
compile files('libs/360update-7.0.3.jar')
清单文件
<!--360自动更新配置开始-->
<activity android:name="com.qihoo.appstore.common.updat esdk.lib.UpdateTipDialogActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<service android:name="com.qihoo.appstore.updatelib.CheckUpdateService"
android:exported="false"/>
//authorities必须修改为您的包名
<provider android:name="com.qihoo.appstore.updatelib.UpdateProvider"
android:authorities="你的包名"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/update_apk_path"/>
</provider>
<!--360自动更新配置结束-->
XML
在资源res目录下添加xml目录,并放入update_apk_path.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path name="qihoo_update" path="360Download/"/>
</paths>