Android的 - [Xoom的/蜂窝]应用程序,而不LAUNCHER活动不工作而不、蜂窝、应用程序、工作

2023-09-04 07:14:53 作者:我的世界我主宰

我有没有启动的活动,工​​作正常,从Android 1.5的到Android 2.3.4的应用程序。它是通过我的广播接收机启动。然而,在蜂窝(摩托罗拉Xoom),我的广播接收器根本不工作(它没有捕获任何意图)。如果我想补充的发射活动,我的清单:

I have an application without launcher activity that works properly from Android 1.5 to Android 2.3.4. It is started by my broadcast receiver. However, on Honeycomb (Motorola Xoom), my broadcast receiver doesn't work at all (it does not catch any intents). If I add launcher activity to my manifest:

<activity android:label="@string/app_name" android:name="com.myapp.MainActivity"> 
<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<category android:name="android.intent.category.LAUNCHER" /> </intent-filter> 
</activity>

然后我的应用程序工作正常(广播接收器捕获所有必要的意图和开始我的服务)。

Then my app works properly (broadcast receiver catches all necessary intents and starts my services).

我会很感激的帮助!

推荐答案

您运行蜂窝3.1或以上?如果是的话看看这里。 当安装了应用程序,它是处于停止状态。当应用程序第一次运行,它被移出停止状态。

Are you running Honeycomb 3.1 or above? If yes take a look here. When your application is installed, it is in stopped state. When the application is first launched, it is moved out of stopped state.

在停止状态下的应用程序不会得到所有广播意图开始。广播意图的发送者可以指定Intent.FLAG_INCLUDE_STOPPED_PACKAGES如果要发动停止的应用程序也标志。

A application in stopped state won't get started by all broadcast intents. The sender of the broadcast intent has to specify the Intent.FLAG_INCLUDE_STOPPED_PACKAGES flag if it wants to launch stopped applications too.

Intent intent = new Intent(MY_INTENT_ACTION);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
sendBroadcast(intent);

如果您不能更改code,它发送的意图,最好的办法是保持发射活动。只要用户安装后,启动应用程序,它会在停止状态的迁出,你会开始接收广播。

If you can't change the code which sends the intent, your best bet would be to keep the launcher activity. Whenever the user launches your application after installation, it will be moved out of the stopped state and you will start receiving broadcasts.

请注意了,用户可以将应用程序返回到停止状态的管理应用程序的设备的设置。

Note the the user can move your application back to the stopped state from Manage Applications in device settings.