在做个应用升级的模块
一、将网络请求在放service中进行,避免因其调用的activity销毁后出错
1.1、本想在service中打开对话框,
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
stopSelf();
}
});
//需要用户在权限列表中同意
Window window = alertDialog.getWindow();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
window.setType(WindowManager.LayoutParams.TYPE_TOAST);
} else {
window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
}
Android悬浮窗TYPE_TOAST小结: 源码分析
1.2 总觉得不安全,打开个activity对话框吧,心里有
Intent intent = new Intent(this, ConfirmDialogActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("bean", bean);
startActivity(intent);