Closed aije closed 2 years ago
这是你自己代码写的有问题,知道嘛。 handler创建请指明Looper, 不要在子线程里面创建handler
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
XUpdate.newBuild(this)
.updateUrl("http://192.168.1.151/update.json")
.updatePrompter(new CustomUpdatePrompter())
.update();
}
}
private void initUpdae(){ XUpdate.get() .debug(true) //设置默认只有在Wifi下检测版本 .isWifiOnly(false) //默认使用get检查版本 .isGet(true) //默认设置非自动模式,可以根据情况使用配置 .isAutoMode(false) //设置默认公共请求参数 .param("versionCode" , UpdateUtils.getVersionCode(this)) .param("appKey" , getPackageName()) //设置版本更新出错监听 .setOnUpdateFailureListener(new OnUpdateFailureListener() { @Override public void onFailure(UpdateError error) { System.out.println(error.toString()); error.printStackTrace(); if (error.getCode() != CHECK_NO_NEW_VERSION){ System.out.println(error.toString()); } } }) //设置是否支持静默安装,默认是true .supportSilentInstall(false) .setIUpdateHttpService(new OKHttpUpdateHttpService()) .init(this); }
这是你自己代码写的有问题,知道嘛。 handler创建请指明Looper, 不要在子线程里面创建handler
.updatePrompter(new CustomUpdatePrompter())
注释上面的代码就没有问题。
使用自定义弹窗提示。 XUpdate.newBuild(BaseApplication.getApplication()) .updateUrl("http://192.168.1.151/update.json") .updatePrompter(new CustomUpdatePrompter()) .update();
报错提示: W/System.err: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()