Android - [Xoom/Honeycomb] application without LAUNCHER activity does not work

后端 未结 2 1861
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 06:04

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 (Motorol

2条回答
  •  甜味超标
    2020-12-16 06:50

    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.

    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);
    

    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.

提交回复
热议问题