Create an automatic launch-able Broadcast Receiver in Android

前端 未结 2 1281
遇见更好的自我
遇见更好的自我 2021-01-28 19:24

Problem:

I am willing to create an application that simply starts as a background process and whenever a new message comes into the device it should log

2条回答
  •  星月不相逢
    2021-01-28 20:22

    You need to add an activity, then run that activity, before this BroadcastReceiver will work.

    More accurately, something needs to use an explicit Intent before your app will be moved out of the stopped state and allow manifest-registered BroadcastReceivers to work. The simplest way to do that is to have a launcher activity, and run that activity from the launcher.

    To learn more, see "Launch controls on stopped applications" in the Android 3.1 release notes, along with this blog post.

提交回复
热议问题