{"id":939,"date":"2022-07-16T04:09:15","date_gmt":"2023-07-23T17:02:40","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/index.php\/2023\/11\/30\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/"},"modified":"2025-08-01T03:42:06","modified_gmt":"2025-07-31T18:42:06","slug":"android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/","title":{"rendered":"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb"},"content":{"rendered":"<p>\u4eca\u65e5\u306f\u3001Android\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u975e\u5e38\u306b\u91cd\u8981\u306a\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3042\u308bAndroid BroadcastReceiver\u306e\u8a71\u3057\u5408\u3044\u3068\u5b9f\u88c5\u306b\u3064\u3044\u3066\u53d6\u308a\u4e0a\u3052\u307e\u3059\u3002<\/p>\n<h2>\u30a2\u30f3\u30c9\u30ed\u30a4\u30c9\u306e\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc<\/h2>\n<p>Android\u306eBroadcastReceiver\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u5168\u4f53\u306e\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30a4\u30d9\u30f3\u30c8\u3084\u30a4\u30f3\u30c6\u30f3\u30c8\u3092\u53d7\u3051\u53d6\u308bAndroid\u306e\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3059\u3002\u3053\u308c\u3089\u306e\u30a4\u30d9\u30f3\u30c8\u304c\u767a\u751f\u3059\u308b\u3068\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306b\u901a\u77e5\u3092\u4f5c\u6210\u3057\u305f\u308a\u3001\u30bf\u30b9\u30af\u3092\u5b9f\u884c\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30a2\u30af\u30c6\u30a3\u30d6\u306b\u3057\u307e\u3059\u3002\u30a2\u30af\u30c6\u30a3\u30d3\u30c6\u30a3\u3068\u306f\u7570\u306a\u308a\u3001Android\u306eBroadcastReceiver\u306b\u306f\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306f\u542b\u307e\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u306f\u3001\u53d7\u4fe1\u3055\u308c\u305f\u30a4\u30f3\u30c6\u30f3\u30c8\u30c7\u30fc\u30bf\u306e\u30bf\u30a4\u30d7\u306b\u5fdc\u3058\u3066\u3001\u30bf\u30b9\u30af\u3092\u30b5\u30fc\u30d3\u30b9\u306b\u59d4\u4efb\u3059\u308b\u305f\u3081\u306b\u4e00\u822c\u7684\u306b\u5b9f\u88c5\u3055\u308c\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u91cd\u8981\u306a\u30b7\u30b9\u30c6\u30e0\u5168\u4f53\u306e\u751f\u6210\u30a4\u30f3\u30c6\u30f3\u30c8\u306e\u3044\u304f\u3064\u304b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>android.intent.action.BATTERY_LOW\uff1a\u30c7\u30d0\u30a4\u30b9\u306e\u30d0\u30c3\u30c6\u30ea\u30fc\u304c\u4f4e\u3044\u72b6\u614b\u3092\u793a\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>android.intent.action.BOOT_COMPLETED\uff1a\u30b7\u30b9\u30c6\u30e0\u306e\u8d77\u52d5\u304c\u5b8c\u4e86\u3057\u305f\u5f8c\u3001\u4e00\u5ea6\u653e\u9001\u3055\u308c\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>android.intent.action.CALL\uff1a\u30c7\u30fc\u30bf\u3067\u6307\u5b9a\u3055\u308c\u305f\u76f8\u624b\u306b\u901a\u8a71\u3092\u884c\u3046\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>android.intent.action.DATE_CHANGED\uff1a\u65e5\u4ed8\u304c\u5909\u66f4\u3055\u308c\u307e\u3057\u305f\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>android.intent.action.REBOOT\uff1a\u30c7\u30d0\u30a4\u30b9\u3092\u518d\u8d77\u52d5\u3055\u305b\u307e\u3059\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>android.net.conn.CONNECTIVITY_CHANGE\uff1a\u30e2\u30d0\u30a4\u30eb\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u307e\u305f\u306fWi-Fi\u63a5\u7d9a\u304c\u5909\u66f4\u3055\u308c\u305f\uff08\u307e\u305f\u306f\u30ea\u30bb\u30c3\u30c8\u3055\u308c\u305f\uff09\u3053\u3068\u3092\u793a\u3057\u307e\u3059\u3002<\/ol>\n<h3>Android\u306b\u304a\u3051\u308b\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc<\/h3>\n<p>Android\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u306b\u306f\u3001\u6b21\u306e2\u3064\u306e\u3053\u3068\u3092\u884c\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u3092\u4f5c\u6210\u3059\u308b<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u3092\u767b\u9332\u3059\u308b<\/ol>\n<h3>\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc\u306e\u4f5c\u6210<\/h3>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3001\u30ab\u30b9\u30bf\u30e0\u306eBroadcastReceiver\u3092\u8fc5\u901f\u306b\u5b9f\u88c5\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"post-pre\"><code>public class MyReceiver extends BroadcastReceiver {\r\n    public MyReceiver() {\r\n    }\r\n \r\n    @Override\r\n    public void onReceive(Context context, Intent intent) {\r\n      \r\n        Toast.makeText(context, \"Action: \" + intent.getAction(), Toast.LENGTH_SHORT).show();\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc\u306f\u3001onReceiver()\u30e1\u30bd\u30c3\u30c9\u3092\u6301\u3064\u62bd\u8c61\u30af\u30e9\u30b9\u3067\u3059\u3002onReceiver()\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30a4\u30d9\u30f3\u30c8\u304c\u767a\u751f\u3057\u305f\u3068\u304d\u306b\u767b\u9332\u3055\u308c\u305f\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc\u306b\u6700\u521d\u306b\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002\u30a4\u30f3\u30c6\u30f3\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u3001\u3059\u3079\u3066\u306e\u8ffd\u52a0\u30c7\u30fc\u30bf\u3068\u5171\u306b\u6e21\u3055\u308c\u307e\u3059\u3002\u307e\u305f\u3001Context\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3082\u5229\u7528\u53ef\u80fd\u3067\u3042\u308a\u3001context.startActivity(myIntent);\u307e\u305f\u306fcontext.startService(myService);\u3092\u4f7f\u7528\u3057\u3066\u30a2\u30af\u30c6\u30a3\u30d3\u30c6\u30a3\u3084\u30b5\u30fc\u30d3\u30b9\u3092\u8d77\u52d5\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3>Android\u30a2\u30d7\u30ea\u3067\u306eBroadcastReceiver\u306e\u767b\u9332\u3092\u884c\u3046<\/h3>\n<p>\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc\u306f2\u3064\u306e\u65b9\u6cd5\u3067\u767b\u9332\u3067\u304d\u307e\u3059\u3002<\/p>\n<ol>\u4ee5\u4e0b\u306e\u3088\u3046\u306bAndroidManifest.xml\u30d5\u30a1\u30a4\u30eb\u3067\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3002<\/ol>\n<pre class=\"post-pre\"><code>&lt;receiver android:name=\".ConnectionReceiver\" &gt;\r\n             &lt;intent-filter&gt;\r\n                 &lt;action android:name=\"android.net.conn.CONNECTIVITY_CHANGE\" \/&gt;\r\n             &lt;\/intent-filter&gt;\r\n&lt;\/receiver&gt;\r\n<\/code><\/pre>\n<p>\u610f\u56f3\u30d5\u30a3\u30eb\u30bf\u30fc\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30b7\u30b9\u30c6\u30e0\u306b\u3001\u30b5\u30d6\u30a8\u30ec\u30e1\u30f3\u30c8\u306b\u4e00\u81f4\u3059\u308b\u610f\u56f3\u306f\u7279\u5b9a\u306e\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc\u306b\u914d\u4fe1\u3055\u308c\u308b\u3079\u304d\u3067\u3042\u308b\u3068\u4f1d\u3048\u307e\u3059\u30023. \u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc\u3092\u767b\u9332\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u4f8b\u304c\u6b21\u306e\u30b9\u30cb\u30da\u30c3\u30c8\u306b\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>IntentFilter filter = new IntentFilter();\r\nintentFilter.addAction(getPackageName() + \"android.net.conn.CONNECTIVITY_CHANGE\");\r\n \r\nMyReceiver myReceiver = new MyReceiver();\r\nregisterReceiver(myReceiver, filter);\r\n<\/code><\/pre>\n<p>\u30a2\u30af\u30c6\u30a3\u30d3\u30c6\u30a3\u306eonStop()\u3084onPause()\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc\u306e\u767b\u9332\u3092\u89e3\u9664\u3059\u308b\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30b9\u30cb\u30da\u30c3\u30c8\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>@Override\r\nprotected void onPause() {\r\n    unregisterReceiver(myReceiver);\r\n    super.onPause();\r\n}\r\n<\/code><\/pre>\n<h3>\u30a2\u30af\u30c6\u30a3\u30d3\u30c6\u30a3\u304b\u3089\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30a4\u30f3\u30c6\u30f3\u30c8\u3092\u9001\u4fe1\u3059\u308b\u3002<\/h3>\n<p>\u95a2\u9023\u3059\u308b\u3059\u3079\u3066\u306eBroadcastReceiver\u306b\u30a4\u30f3\u30c6\u30f3\u30c8\u3092\u9001\u4fe1\u3059\u308b\u305f\u3081\u306b\u3001\u4ee5\u4e0b\u306e\u30b9\u30cb\u30da\u30c3\u30c8\u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>Intent intent = new Intent();\r\n      intent.setAction(\"com.scdev.CUSTOM_INTENT\");\r\n      sendBroadcast(intent);\r\n<\/code><\/pre>\n<p>\u30de\u30cb\u30d5\u30a7\u30b9\u30c8\u307e\u305f\u306f\u30d7\u30ed\u30b0\u30e9\u30e0\u4e0a\u306e\u30a4\u30f3\u30c6\u30f3\u30c8\u30d5\u30a3\u30eb\u30bf\u30fc\u30bf\u30b0\u306b\u4e0a\u8a18\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3092\u5fd8\u308c\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u5909\u66f4\u30a4\u30d9\u30f3\u30c8\u3084\u30ab\u30b9\u30bf\u30e0\u30a4\u30f3\u30c6\u30f3\u30c8\u3092\u805e\u304d\u53d6\u308b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u958b\u767a\u3057\u307e\u3057\u3087\u3046\u3002\u305d\u3057\u3066\u3001\u30c7\u30fc\u30bf\u3092\u9069\u5207\u306b\u51e6\u7406\u3057\u307e\u3059\u3002<\/p>\n<h3>Android\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u69cb\u9020\u5185\u306eBroadcastReceiver<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564a030daa94e2bdf7c278f\/24-0.png\" alt=\"android broadcastreceiver example, BroadcastReceiver in Android\" \/><\/div>\n<h3>\u30a2\u30f3\u30c9\u30ed\u30a4\u30c9\u306e\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc\u30b3\u30fc\u30c9<\/h3>\n<p>activity_main.xml\u306b\u306f\u3001\u4e2d\u592e\u306b\u914d\u7f6e\u3055\u308c\u305f\u30dc\u30bf\u30f3\u304c\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30a4\u30f3\u30c6\u30f3\u30c8\u3092\u9001\u4fe1\u3059\u308b\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;RelativeLayout xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:tools=\"https:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:paddingBottom=\"@dimen\/activity_vertical_margin\"\r\n    android:paddingLeft=\"@dimen\/activity_horizontal_margin\"\r\n    android:paddingRight=\"@dimen\/activity_horizontal_margin\"\r\n    android:paddingTop=\"@dimen\/activity_vertical_margin\"\r\n    tools:context=\"com.scdev.broadcastreceiver.MainActivity\"&gt;\r\n\r\n    &lt;Button\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:id=\"@+id\/button\"\r\n        android:text=\"Send Broadcast\"\r\n        android:layout_centerVertical=\"true\"\r\n        android:layout_centerHorizontal=\"true\" \/&gt;\r\n&lt;\/RelativeLayout&gt;\r\n<\/code><\/pre>\n<p>\u4e0b\u8a18\u306fMainActivity.java\u3067\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.broadcastreceiver;\r\n\r\nimport android.content.Intent;\r\nimport android.content.IntentFilter;\r\nimport android.support.v7.app.AppCompatActivity;\r\nimport android.os.Bundle;\r\nimport android.util.Log;\r\nimport android.view.View;\r\nimport android.widget.Button;\r\n\r\nimport butterknife.ButterKnife;\r\nimport butterknife.InjectView;\r\nimport butterknife.OnClick;\r\n\r\npublic class MainActivity extends AppCompatActivity {\r\n    ConnectionReceiver receiver;\r\n    IntentFilter intentFilter;\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n\r\n        ButterKnife.inject(this);\r\n\r\n        receiver = new ConnectionReceiver();\r\n        intentFilter = new IntentFilter(\"com.scdev.broadcastreceiver.SOME_ACTION\");\r\n\r\n    }\r\n\r\n    @Override\r\n    protected void onResume() {\r\n        super.onResume();\r\n        registerReceiver(receiver, intentFilter);\r\n\r\n    }\r\n\r\n    @Override\r\n    protected void onDestroy() {\r\n        super.onDestroy();\r\n\r\n        unregisterReceiver(receiver);\r\n    }\r\n\r\n    @OnClick(R.id.button)\r\n    void someMethod() {\r\n\r\n        Intent intent = new Intent(\"com.scdev.broadcastreceiver.SOME_ACTION\");\r\n        sendBroadcast(intent);\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u5225\u306e\u30ab\u30b9\u30bf\u30e0\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u767b\u9332\u3057\u307e\u3057\u305f\u3002ConnectionReceiver\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bAndroidManifest.xml\u30d5\u30a1\u30a4\u30eb\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;manifest xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"\r\n    package=\"com.scdev.broadcastreceiver\"&gt;\r\n\r\n    &lt;uses-permission android:name=\"android.permission.INTERNET\" \/&gt;\r\n    &lt;uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" \/&gt;\r\n\r\n    &lt;application\r\n        android:allowBackup=\"true\"\r\n        android:icon=\"@mipmap\/ic_launcher\"\r\n        android:label=\"@string\/app_name\"\r\n        android:supportsRtl=\"true\"\r\n        android:theme=\"@style\/AppTheme\"&gt;\r\n        &lt;activity android:name=\".MainActivity\"&gt;\r\n            &lt;intent-filter&gt;\r\n                &lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\r\n                &lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\r\n            &lt;\/intent-filter&gt;\r\n        &lt;\/activity&gt;\r\n\r\n        &lt;receiver android:name=\".ConnectionReceiver\"&gt;\r\n            &lt;intent-filter&gt;\r\n                &lt;action android:name=\"android.net.conn.CONNECTIVITY_CHANGE\" \/&gt;\r\n            &lt;\/intent-filter&gt;\r\n        &lt;\/receiver&gt;\r\n\r\n    &lt;\/application&gt;\r\n&lt;\/manifest&gt;\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0b\u306b\u306f\u3001ConnectionReceiver.java\u30af\u30e9\u30b9\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>public class ConnectionReceiver extends BroadcastReceiver {\r\n    @Override\r\n    public void onReceive(Context context, Intent intent) {\r\n\r\n        Log.d(\"API123\",\"\"+intent.getAction());\r\n\r\n        if(intent.getAction().equals(\"com.scdev.broadcastreceiver.SOME_ACTION\"))\r\n            Toast.makeText(context, \"SOME_ACTION is received\", Toast.LENGTH_LONG).show();\r\n\r\n        else {\r\n            ConnectivityManager cm =\r\n                    (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);\r\n\r\n            NetworkInfo activeNetwork = cm.getActiveNetworkInfo();\r\n            boolean isConnected = activeNetwork != null &amp;&amp;\r\n                    activeNetwork.isConnectedOrConnecting();\r\n            if (isConnected) {\r\n                try {\r\n                    Toast.makeText(context, \"Network is connected\", Toast.LENGTH_LONG).show();\r\n                } catch (Exception e) {\r\n                    e.printStackTrace();\r\n                }\r\n            } else {\r\n                Toast.makeText(context, \"Network is changed or reconnected\", Toast.LENGTH_LONG).show();\r\n            }\r\n        }\r\n    }\r\n\r\n}\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564a030daa94e2bdf7c278f\/34-0.gif\" alt=\"android broadcast receiver app\" \/><\/div>\n<p>Android\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u65e5\u306f\u3001Android\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u975e\u5e38\u306b\u91cd\u8981\u306a\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3042\u308bAndroid BroadcastReceiver\u306e\u8a71\u3057\u5408\u3044\u3068\u5b9f\u88c5\u306b\u3064\u3044\u3066\u53d6\u308a\u4e0a\u3052\u307e\u3059\u3002 \u30a2\u30f3\u30c9\u30ed\u30a4\u30c9\u306e\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8\u30ec\u30b7\u30fc\u30d0\u30fc Android\u306eB [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26,61],"class_list":["post-939","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-26","tag-61"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\" \/>\n<meta property=\"og:description\" content=\"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-23T17:02:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T18:42:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564a030daa94e2bdf7c278f\/24-0.png\" \/>\n<meta name=\"author\" content=\"\u7d50\u8863, \u6625\u82b1\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u7d50\u8863, \u6625\u82b1\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"16\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/\",\"name\":\"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2023-07-23T17:02:40+00:00\",\"dateModified\":\"2025-07-31T18:42:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/e52a686063ac76fd8cc6f539d41497ac\"},\"description\":\"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/e52a686063ac76fd8cc6f539d41497ac\",\"name\":\"\u7d50\u8863, \u6625\u82b1\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c74c6e2eb915a3c8e795b3934aa25a7333e0b38e7f1c7baf52785286ad51105e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c74c6e2eb915a3c8e795b3934aa25a7333e0b38e7f1c7baf52785286ad51105e?s=96&d=mm&r=g\",\"caption\":\"\u7d50\u8863, \u6625\u82b1\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/yuiharuka\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb - Blog - Silicon Cloud","description":"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\/","og_locale":"ja_JP","og_type":"article","og_title":"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb","og_description":"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-07-23T17:02:40+00:00","article_modified_time":"2025-07-31T18:42:06+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/6564a030daa94e2bdf7c278f\/24-0.png"}],"author":"\u7d50\u8863, \u6625\u82b1","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u7d50\u8863, \u6625\u82b1","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"16\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/","name":"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2023-07-23T17:02:40+00:00","dateModified":"2025-07-31T18:42:06+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/e52a686063ac76fd8cc6f539d41497ac"},"description":"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"Android BroadcastReceiver\u306e\u4f8b\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/e52a686063ac76fd8cc6f539d41497ac","name":"\u7d50\u8863, \u6625\u82b1","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c74c6e2eb915a3c8e795b3934aa25a7333e0b38e7f1c7baf52785286ad51105e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c74c6e2eb915a3c8e795b3934aa25a7333e0b38e7f1c7baf52785286ad51105e?s=96&d=mm&r=g","caption":"\u7d50\u8863, \u6625\u82b1"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/yuiharuka\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/android-broadcastreceiver%e3%81%ae%e4%be%8b%e3%81%ae%e3%83%81%e3%83%a5%e3%83%bc%e3%83%88%e3%83%aa%e3%82%a2%e3%83%ab\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/939","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=939"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/939\/revisions"}],"predecessor-version":[{"id":46905,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/939\/revisions\/46905"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}