【问题标题】:Broadcast receiver not triggered after app is stopped应用停止后未触发广播接收器
【发布时间】:2013-03-05 05:05:43
【问题描述】:

我在清单中定义了一个广播接收器,在意图过滤器中使用 android.bluetooth.device.action.ACL_CONNECTED。

当应用程序在堆栈中时触发正常,但在我从 android 设置中停止它后它不会再触发。有什么建议吗?

Menny 更新:

<receiver android:name=".auto.AppLauncher">
   <intent-filter>
        <action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
   </intent-filter>
</receiver>

【问题讨论】:

  • 您能补充更多信息吗?就像您声明过滤器的 AndroidManifest 中的 sn-p 等?

标签: android bluetooth broadcastreceiver intentfilter activity-lifecycle


【解决方案1】:

您是否在代码中编写了广播接收器?

    public class receiver extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
            if(intent.getAction().equals(BluetoothDevice.ACTION_ACL_CONNECTED)) {
                    //something you want to do here
            }
        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多