- 構文:
<receiver android:directBootAware=["true" | "false"] android:enabled=["true" | "false"] android:exported=["true" | "false"] android:icon="drawable resource" android:label="string resource" android:name="string" android:permission="string" android:process="string" > ... </receiver>
- 上位の要素:
<application>
- 含めることのできる要素:
<intent-filter>
<meta-data>
- 説明:
- ブロードキャスト レシーバ(
BroadcastReceiver
サブクラス)をアプリのコンポーネントの一つとして宣言します。ブロードキャスト レシーバを使用すると、アプリの他のコンポーネントが実行されていない場合でも、システムまたは他のアプリからブロードキャストされたインテントをアプリで受信できます。ブロードキャスト レシーバの存在をシステムに知らせる方法は 2 つあります。一つは、マニフェスト ファイルでこの要素を使用して宣言する方法です。もう一つは、コードでレシーバを動的に作成して、
Context.registerReceiver()
メソッドかオーバーロードされたいずれかのバージョンで登録する方法です。レシーバを動的に作成する方法について詳しくは、
BroadcastReceiver
クラスの説明をご覧ください。このレシーバがシステム以外のブロードキャストを処理する場合は、
android:exported
の値を指定します。レシーバが他のアプリからのブロードキャストを受信できるようにする場合は、この値を"true"
に設定し、レシーバが自身のアプリからのブロードキャストのみを受信できるようにする場合は、"false"
に設定します。android:permission
属性をすでに宣言している場合は、削除する必要はありません。警告: アプリで設定するブロードキャスト レシーバの数を制限してください。ブロードキャスト レシーバが多すぎると、アプリのパフォーマンスやユーザーのデバイスのバッテリー駆動時間に影響することがあります。バックグラウンド処理のスケジュール設定用に
BroadcastReceiver
クラスの代わりに使用できる API について詳しくは、バックグラウンド処理の最適化をご覧ください。 - 属性:
android:directBootAware
ブロードキャスト レシーバがダイレクト ブートに対応しているかどうか、つまり、ユーザーがデバイスのロックを解除する前にアクティビティを実行できるかどうか。
注: ダイレクト ブート中、アプリのブロードキャスト レシーバはデバイス保護ストレージに保存されているデータにのみアクセスできます。
デフォルト値は
"false"
です。android:enabled
- システムがブロードキャスト レシーバをインスタンス化できるかどうか。できる場合は
"true"
、できない場合は"false"
です。デフォルト値は"true"
です。<application>
要素には、ブロードキャスト レシーバを含むすべてのアプリ コンポーネントに適用される独自のenabled
属性があります。ブロードキャスト レシーバを有効にするには、<application>
属性と<receiver>
属性の両方を"true"
に設定する必要があります。いずれかが"false"
の場合、無効になり、インスタンス化できません。 android:exported
- ブロードキャスト レシーバがアプリ外のシステム以外のソースからメッセージを受信できるかどうかを指定します。できる場合は
"true"
、できない場合は"false"
です。"false"
に設定すると、ブロードキャスト レシーバは、システム、同じアプリのコンポーネント、またはユーザー ID が同一のアプリから送信されたメッセージしか受信できなくなります。指定しない場合のデフォルト値は、ブロードキャスト レシーバにインテント フィルタが含まれているかどうかによって異なります。レシーバにインテント フィルタが 1 つ以上含まれている場合、デフォルト値は「
"true"
」です。それ以外の場合のデフォルト値は"false"
です。この属性を使用すること以外にもブロードキャスト レシーバの外部への公開を制限する方法はあります。ブロードキャスト レシーバにメッセージを送信可能な外部エンティティを制限する権限を使用することもできます。
permission
属性をご覧ください。 android:icon
- ブロードキャスト レシーバを表すアイコン。この属性は、画像の定義を含むドローアブル リソースへの参照として設定されます。この属性を設定しなかった場合、アプリ用に指定されているアイコンが代わりに使用されます。
<application>
要素のicon
属性をご覧ください。ブロードキャスト レシーバのアイコンは、この属性と
<application>
要素のどちらで設定したかに関係なく、レシーバのすべてのインテント フィルタのデフォルト アイコンにもなります(<intent-filter>
要素のicon
属性を参照)。 android:label
- ユーザーが読むことができる、ブロードキャスト レシーバ用のラベル。この属性を設定しなかった場合、アプリ用に設定されているラベルが代わりに使用されます。
<application>
要素のlabel
属性をご覧ください。ブロードキャスト レシーバのラベルは、この属性と
<application>
要素のどちらで設定したかに関係なく、レシーバのすべてのインテント フィルタのデフォルト ラベルにもなります(<intent-filter>
要素のlabel
属性を参照)。ラベルは文字列リソースへの参照として設定します。そうすることで、ユーザー インターフェースの他の文字列と同じようにローカライズできるようになります。ただし、アプリ開発の便宜上、未加工の文字列として設定することもできます。
android:name
- ブロードキャスト レシーバ(
BroadcastReceiver
のサブクラス)を実装するクラスの名前。これは完全修飾クラス名です("com.example.project.ReportReceiver"
など)。ただし、".ReportReceiver"
のように短縮形として名前の最初の文字をピリオドにした場合、<manifest>
要素で指定したパッケージ名に付加されます。アプリの公開後は、
android:exported="false"
を設定しない限り、この名前を変更しないでください。デフォルト値はありません。名前の指定は必須です。
android:permission
- ブロードキャストの送信者がブロードキャスト レシーバにメッセージを送信するために必要な権限の名前。この属性が設定されていない場合、
<application>
要素のpermission
属性で設定された権限がブロードキャスト レシーバに適用されます。どちらの属性も設定されていない場合、レシーバは権限によって保護されません。権限についての詳細は、アプリ マニフェスト概要の権限のセクションと、セキュリティに関するヒントをご覧ください。
android:process
- ブロードキャスト レシーバの実行プロセスの名前。通常、アプリ コンポーネントはすべて、そのアプリ用に作成されたデフォルト プロセス内で実行されます。このプロセスの名前はアプリ パッケージと同じです。
<application>
要素のprocess
属性を使用すると、すべてのコンポーネントに対して異なるデフォルト値を設定できます。ただし、各コンポーネントは、それぞれのprocess
属性でデフォルト値をオーバーライドできます。これにより、アプリを複数のプロセスに分散できます。この属性に割り当てられた名前がコロン(「
:
」)で始まる場合、必要に応じてアプリ専用の新しいプロセスが作成され、そのプロセス内でブロードキャスト レシーバが実行されます。プロセス名が小文字で始まる場合、レシーバはその名前のグローバル プロセス内で実行されます(その権限がある場合)。これにより、異なるアプリのコンポーネント間で 1 つのプロセスを共有して、リソース使用量を削減できます。
- 導入時の API レベル:
- API レベル 1
<受信者>
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# <receiver\u003e\n\nsyntax:\n:\n\n ```xml\n \u003creceiver android:directBootAware=[\"true\" | \"false\"]\n android:enabled=[\"true\" | \"false\"]\n android:exported=[\"true\" | \"false\"]\n android:icon=\"drawable resource\"\n android:label=\"string resource\"\n android:name=\"string\"\n android:permission=\"string\"\n android:process=\"string\" \u003e\n ...\n \u003c/receiver\u003e\n ```\n\ncontained in:\n: [\u003capplication\u003e](/guide/topics/manifest/application-element)\n\ncan contain:\n: [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element)\n\n [\u003cmeta-data\u003e](/guide/topics/manifest/meta-data-element)\n\ndescription:\n: Declares a broadcast receiver, a [BroadcastReceiver](/reference/android/content/BroadcastReceiver)\n subclass, as one of the application's components. Broadcast receivers enable\n applications to receive intents that are broadcast by the system or by other\n applications, even when other components of the application aren't running.\n\n\n There are two ways to make a broadcast receiver known to the system. One is to\n declare it in the manifest file with this element. The other is to create\n the receiver dynamically in code and register it with the\n [Context.registerReceiver()](/reference/android/content/Context#registerReceiver(android.content.BroadcastReceiver,%20android.content.IntentFilter))\n method or one of its overloaded versions.\n\n\n For more information about how to dynamically create receivers, see the\n [BroadcastReceiver](/reference/android/content/BroadcastReceiver) class\n description.\n\n\n If this receiver handles non-system broadcasts, specify a value for `android:exported`.\n Set this value to `\"true\"` if you want your receiver to be able to\n receiver broadcasts from other applications or `\"false\"` if you only\n want your receiver to be able to receive broadcasts from your own app.\n\n\n You don't have to remove the `android:permission` attribute if you\n already declared it.\n\n\n **Warning:** Limit how many broadcast\n receivers you set in your app. Having too many broadcast receivers can\n affect your app's performance and the battery life of users' devices.\n For more information about APIs you can use instead of the\n `BroadcastReceiver` class for scheduling background work, see\n [Background optimization](/topic/performance/background-optimization).\n\nattributes:\n:\n\n `android:directBootAware`\n\n : Whether the broadcast receiver is *Direct-Boot aware*, that\n is, whether it can run before the user unlocks the device.\n\n **Note:** During\n [Direct Boot](/training/articles/direct-boot), a broadcast\n receiver in your application can only access the data that is stored in\n *device protected* storage.\n\n The default value is `\"false\"`.\n\n `android:enabled`\n : Whether the broadcast receiver can be instantiated by the system. It's\n `\"true\"` if it can be, and `\"false\"` if not. The default value\n is `\"true\"`.\n\n\n The [\u003capplication\u003e](/guide/topics/manifest/application-element) element has its own\n [enabled](/guide/topics/manifest/application-element#enabled) attribute that applies to all\n application components, including broadcast receivers. The\n `\u003capplication\u003e` and\n `\u003creceiver\u003e` attributes must both be `\"true\"` for\n the broadcast receiver to be enabled. If either is `\"false\"`, it's\n disabled and can't be instantiated.\n\n `android:exported`\n : Whether the broadcast receiver can receive messages from non-system sources\n outside its application. It's `\"true\"` if it can, and `\"false\"`\n if not. If `\"false\"`, the only messages the broadcast receiver\n receives are those sent by the system, components of the same application, or applications\n with the same user ID.\n\n\n If unspecified, the default value depends on whether the broadcast receiver contains intent\n filters. If the receiver contains at least one intent filter, then the default value is\n `\"true\"`. Otherwise, the default value is `\"false\"`.\n\n\n This attribute is not the only way to limit a broadcast receiver's external exposure.\n You can also use a permission to limit the external entities that can send it messages.\n See the [permission](/guide/topics/manifest/receiver-element#prmsn) attribute.\n\n `android:icon`\n : An icon representing the broadcast receiver. This attribute is set\n as a reference to a drawable resource containing the image definition.\n If it isn't set, the icon specified for the application as a whole is used\n instead. See the [\u003capplication\u003e](/guide/topics/manifest/application-element)\n element's [icon](/guide/topics/manifest/application-element#icon) attribute.\n\n\n The broadcast receiver's icon, whether set here or by the\n `\u003capplication\u003e` element, is also the\n default icon for all the receiver's intent filters. See the\n [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element) element's\n [icon](/guide/topics/manifest/intent-filter-element#icon) attribute.\n\n `android:label`\n : A user-readable label for the broadcast receiver. If this attribute isn't\n set, the label set for the application as a whole is\n used instead. See the [\u003capplication\u003e](/guide/topics/manifest/application-element) element's\n [label](/guide/topics/manifest/application-element#label) attribute.\n\n\n The broadcast receiver's label, whether set here or by the\n `\u003capplication\u003e` element, is also the\n default label for all the receiver's intent filters. See the\n [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element) element's\n [label](/guide/topics/manifest/intent-filter-element#label) attribute.\n\n\n The label is set as a reference to a string resource, so that\n it can be localized like other strings in the user interface.\n However, as a convenience while you're developing the application,\n it can also be set as a raw string.\n\n `android:name`\n : The name of the class that implements the broadcast receiver, a subclass of\n [BroadcastReceiver](/reference/android/content/BroadcastReceiver). This is a fully qualified\n class name, such as `\"com.example.project.ReportReceiver\"`. However,\n as a shorthand, if the first character of the name is a period, for example,\n `\".ReportReceiver\"`, it is appended to the package name specified in\n the [\u003cmanifest\u003e](/guide/topics/manifest/manifest-element) element.\n\n Once you publish your application, [don't\n change this name](http://android-developers.blogspot.com/2011/06/things-that-cannot-change.html), unless you set [android:exported](#exported)`=\"false\"`.\n\n\n There is no default. The name must be specified.\n\n `android:permission`\n : The name of a permission that broadcasters need in order to send a\n message to the broadcast receiver.\n If this attribute isn't set, the permission set by the\n [\u003capplication\u003e](/guide/topics/manifest/application-element) element's\n [permission](/guide/topics/manifest/application-element#prmsn) attribute applies\n to the broadcast receiver. If neither attribute is set, the receiver\n isn't protected by a permission.\n\n\n For more information about permissions, see the\n [Permissions](/guide/topics/manifest/manifest-intro#perms)\n section in the app manifest overview and\n [Security tips](/guide/topics/security/security).\n\n `android:process`\n\n : The name of the process in which the broadcast receiver runs. Normally, all components of an application run in the default process created for the application. It has the same name as the application package.\u003cbr /\u003e\n\n The\n [\u003capplication\u003e](/guide/topics/manifest/application-element) element's\n [process](/guide/topics/manifest/application-element#proc) attribute can set a different\n default for all components. But each component can override the default\n with its own `process` attribute, letting you spread your\n application across multiple processes.\n\n\n If the name assigned to this attribute begins with a colon (`:`), a new\n process, private to the application, is created when it's needed, and\n the broadcast receiver runs in that process.\n\n\n If the process name begins with a lowercase character, the receiver runs\n in a global process of that name, provided that it has permission to do so.\n This lets components in different applications share a process, reducing\n resource usage.\n\nintroduced in:\n: API level 1"]]