安装完成后自动启动的Andr​​oid应用 [英] Autostart Android application after installation complete

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

问题描述

我知道如何引导与 BOOT_COMPLETED 意图动作后自动启动,但我没有找到如何自动启动已经安装在设备上刚结束的应用程序。

I know how to autostart after boot with the BOOT_COMPLETED intent action, but I didn't find how to autostart an application just after it has been installed on the device.

有关我的应用程序,我想设置一个报警安装后,我看着的 PACKAGE_ADDED 原意行动,但它说,新安装包不会收到该广播。

For my application I would like to set an alarm after the install, I looked at the PACKAGE_ADDED intent action but it says that the newly installed package does not receive this broadcast.

任何意见?

在此先感谢

推荐答案

正如你提到的,有没有办法接受自己的 PACKAGE_ADDED 事件;你只需要在每次启动应用程序时检查一个标志。

As you mention, there's no way of receiving your own PACKAGE_ADDED event; you just have to check for a flag each time you start your application.

例如:

SharedPreferences prefs = getPreferences(MODE_PRIVATE);
if (!prefs.contains(KEY_FIRST_RUN)) {
    /* do some one-off stuff here */
    prefs.edit().putBoolean(KEY_FIRST_RUN, false).commit();
}

您可以在应用程序把这个类,或在你的发射器的的onCreate 方法。

You could put this in your Application class, or in your launcher's onCreate method.

这篇关于安装完成后自动启动的Andr​​oid应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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