blob: b419bc690e02ca2611bed3c9ee9030d32fffab65 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE task
PUBLIC "-//OASIS//DTD DITA Task//EN" "../dtd/task.dtd">
<task xml:lang="en-us" id="t_bcast-rcvr-creating">
<title>Adding a broadcast receiver</title>
<shortdesc>Allows you to easily add a new broadcast receiver to an existing Android project. A broadcast receiver
enables you to receive intents sent either from the system or from other applications, even when your application
isn't running.</shortdesc>
<cmd>In the Package Explorer, right-click the project to which the activity should be added and select
<menucascade><uicontrol>New</uicontrol><uicontrol>Android Broadcast
<cmd>Specify a name for your new BroadcastReceiver subclass in <uicontrol>Name</uicontrol>.</cmd>
<cmd>By default the new broadcast receiver will not have a label of its own; the application's label will be
used wherever necessary. If you want a specific label for this broadcast receiver, clear the <uicontrol
>Default</uicontrol> option (next to the <uicontrol>Label</uicontrol> field) and then enter your preferred
user-readable label.</cmd>
<cmd>If this broadcast receiver uses device capabilities for which the user must grant permission, specify them
in the <uicontrol>Permission</uicontrol> area. These permissions will be added to the appropriate place in
your application's manifest file. To specify a permission, click <uicontrol>Add</uicontrol>, select the needed
permission, and click <uicontrol>OK</uicontrol>.</cmd>
<cmd>Specify the types of broadcasts that this new receiver can handle: for each, click <uicontrol
>Add</uicontrol> (next to <uicontrol>Action</uicontrol>) and select the appropriate intent.</cmd>
<cmd>If you need to specify additional information about the intents using one or more standard categories, for
each click <uicontrol>Add</uicontrol> (next to <uicontrol>Category</uicontrol>) and select the appropriate
<cmd>Click <uicontrol>Finish</uicontrol>.</cmd>
<result>The broadcast receiver is created and added to the selected project. It is also opened in an editor