百度自動更新
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.#/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>