执行安装后的And​​r​​oid code [英] Execute Android code after installation

查看:143
本文介绍了执行安装后的And​​r​​oid code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  是否有关于Android的安装情况?

我想执行一段code只有当安装完成后在一个Android应用程序之后。这code不应该在那里后申请执行。

I want to execute a piece of code only once after installation complete in an Android app. This code should never be executed in the application there after.

谁能告诉我如何做到这一点。

Can anyone tell me how to do this.

Reagrds,

尚卡尔

推荐答案

我试过低于code使这项工作的变化,以满足您的需求。

I tried below code to make this work change it to suit your needs

SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);
boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true);
if (isFirstRun)
{
    // Code to run once
    SharedPreferences.Editor editor = wmbPreference.edit();
    editor.putBoolean("FIRSTRUN", false);
    editor.commit();
}

这篇关于执行安装后的And​​r​​oid code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆