我是靠谱客的博主 多情唇膏,这篇文章主要介绍android 弹窗启动,Android:第一次运行弹出对话框,现在分享给大家,希望可以做个参考。

像这样,你可以区分新的安装和更新。

String StoredVersionname = "";

String VersionName;

AlertDialog LoginDialog;

AlertDialog UpdateDialog;

AlertDialog FirstRunDialog;

SharedPreferences prefs;

public static String getVersionName(Context context, Class cls) {

try {

ComponentName comp = new ComponentName(context, cls);

PackageInfo pinfo = context.getPackageManager().getPackageInfo(

comp.getPackageName(), 0);

return "Version: " + pinfo.versionName;

} catch (android.content.pm.PackageManager.NameNotFoundException e) {

return null;

}

}

public void CheckFirstRun() {

VersionName = MyActivity.getVersionName(this, MyActivity.class);

prefs = PreferenceManager.getDefaultSharedPreferences(this);

StoredVersionname = (prefs.getString("versionname", null));

if (StoredVersionname == null || StoredVersionname.length() == 0){

FirstRunDialog = new FirstRunDialog(this);

FirstRunDialog.show();

}else if (StoredVersionname != VersionName) {

UpdateDialog = new UpdateDialog(this);

UpdateDialog.show();

}

prefs.edit().putString("versionname", VersionName).commit();

} 的[确定是否Android应用是使用的第一时间](

最后

以上就是多情唇膏最近收集整理的关于android 弹窗启动,Android:第一次运行弹出对话框的全部内容,更多相关android内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部