改进了一个可以检测版本更新自动下载自动安装的客户端升级方案。
在下载之前删除之前的历史下载文件,减少垃圾数据。
先给出核心类
public class DownloadService extends Service { private DownloadManager mDownloadManager; private long enqueue; private BroadcastReceiver receiver; private static final String APK_URL= IPAddress.DEFAULT_IP+"/portrait/app-youni.apk"; // private static final String APK_NAME="youni.apk"; private static final String APK_NAME="youni_"+ System.currentTimeMillis()+"_.apk"; @Nullable @Override public IBinder onBind(Intent intent) { DebugLog.v("onBind"); return null; } @Override public void onCreate() { DebugLog.v("onCreate"); super