先看效果
使用
package com.ydl.versionupdate;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import com.ydl.appupdate.NewVersion;
public class MainActivity extends Activity {
private Context context = this;
private String downloadPath = "http://192.168.0.116:8080/";
private String appVsrsion = "android_version.json";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
new NewVersion(context, downloadPath,
appVsrsion).checkUpdateVersion();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
serverjson文件内容
[{"app_name":"版本号自己主动更新測试","apkname":"PassportSearch.apk","versionCode":"2","versionName":"1.0.1","apksize":"277883","apkinfo":"1,新增了登录注冊功能。\n1,修复了部分bug!"}]
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步