在Android中打开或关闭Wifi/Bluetooth的通知功能?
我已经为此搜索了很多次,但搜索通常会给出不相关的结果。您知道如何在通知中添加意图,以启用或禁用Wifi(例如)?没有意图更改Wifi状态AFAIk,因此您不能仅使用挂起的意图。你必须把它和广播接收器结合起来 流程是这样的-您的通知将唤醒BroadcastReceiver(您可以做出通知接收器的挂起意图),然后可以使用常规WiFiManager API更改WiFi状态 这是一个有效的实现。在Android中打开或关闭Wifi/Bluetooth的通知功能?,android,android-notifications,Android,Android Notifications,我已经为此搜索了很多次,但搜索通常会给出不相关的结果。您知道如何在通知中添加意图,以启用或禁用Wifi(例如)?没有意图更改Wifi状态AFAIk,因此您不能仅使用挂起的意图。你必须把它和广播接收器结合起来 流程是这样的-您的通知将唤醒BroadcastReceiver(您可以做出通知接收器的挂起意图),然后可以使用常规WiFiManager API更改WiFi状态 这是一个有效的实现。 尝试蓝牙: Intent enableBtIntent = new Intent(Bluetooth
尝试蓝牙:
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(this, 0, enableBtIntent, 0, null);
mBuilder.setContentIntent(resultPendingIntent);
mBuilder.addAction(android.R.drawable.stat_sys_data_bluetooth, getResources().getString(R.string.enable_bluetooth), resultPendingIntent);