我正在尝试从前台服务启动设置,但getActivity()和getService()却无济于事。设置永远不会启动。编辑:这是我如何设置待处理的意图。前台服务会显示一条带有可点击文本行的普通通知
notificationBuilder.setOngoing(true)
Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS));
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
notificationBuilder.addAction([mydrawable], "openSettings", pIntent);
答案 0 :(得分:0)
当我想在单击通知时启动wifi设置时,这对我有用。
val notificationBuilder = NotificationCompat.Builder(context, channelId).apply{setSmallIcon(R.drawable.icon)---<more code here>..
val intent = Intent(Settings.ACTION_WIFI_SETTINGS)
val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
setContentIntent(pendingIntent)}