机器人可以检测一个应用它是如何被推出? [英] Android Can Applicaton Detect How it is being Launched?

查看:95
本文介绍了机器人可以检测一个应用它是如何被推出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为Android应用程序,以检测它是如何被推出?无论是启动或用户启动应用程序列表中的应用程序?

Is there a way for Android application to detect how it is being launched? whether by a BOOT or by user launching the application from the application list?

在我的应用程序在启动时启动,我不希望任何活动,以显示在所有。当用户具体地从应用程序列表启动它,然后才把将欲的主要活动来显示。如果我能发现的推出是否是一个用户启动或系统引导启动,我也许可以对此进行控制。

When my application is launched on boot I don't want any activity to show at all. When the user specifically launches it from the application list, then and only then would I want the main activity to show. If I could detect whether the launch was a user launch or system boot launch I might be able to control this.

推荐答案

您正在寻找的是启动应用程序的意图。在你的Andr​​oid项目的清单文件,你可以指定哪些意图将推出哪些活动。对于意图文档页面实际上有一个非常详尽的解释如何使用这个功能时,例如code和家居:

What you're looking for is the Intent that started the application. In the manifest file of your Android project you can specify which Intents will launch which Activities. The documentation page for Intent actually has a really thorough explanation of how to use this feature, with example code and everything:

http://developer.android.com/reference/android/content/ Intent.html

当用户从一个启动应用程序的样子,将调用的意图:

The Intent that will be called when a user selects your application from a launcher will look like:

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

如果你想有一个不同的活动推出的时候,手机的靴子(有一个意图过滤器值android.intent.action.BOOT_COMPLETED),你只是一个不同的IntentFilter添加到活动的清单中的标签。

If you want a different Activity to launch when the phone boots (there's an intent filter value "android.intent.action.BOOT_COMPLETED"), you just add a different IntentFilter to the Activity's tag in the manifest.

这篇关于机器人可以检测一个应用它是如何被推出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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