简体   繁体   English

如何以编程方式创建wifi连接操作系统设置对话框

[英]How to programatically create wifi connection os setting dialog

I want to design an app which shows a list of wifi networks available and it shows the wifi connection setting dialog box when it is selected. 我想设计一个显示可用wifi网络列表的应用程序,并在选中它时显示wifi连接设置对话框。 Can anyone please tell me how to do this? 谁能告诉我该怎么做?

Use AlarmManager. 使用AlarmManager。 It allows you to send the intent in the specified time. 它允许您在指定的时间发送意图。

Intent startIntent = new Intent("WhatEverYouWant");
PendingIntent startPIntent = PendingIntent.getBroadcast(context, 0, startIntent, 0);
AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarm.set(AlarmManager.RTC_WAKEUP, triggerTime, startPIntent);

In manifest file add your receiver with appropriate action same as in the Intent. 在清单文件中,以与Intent中相同的适当操作添加接收者。 And from your receiver show the notification. 并从您的接收器显示通知。

<receiver android:name="com.package.YourOnReceiver">
   <intent-filter>
       <action android:name="WhatEverYouWant" />
   </intent-filter>
</receiver>

More info on sending Intent using AlarmManager here 有关在此处使用AlarmManager发送Intent的更多信息
https://developer.android.com/reference/android/app/AlarmManager.html#set(int, long, android.app.PendingIntent) https://developer.android.com/reference/android/app/AlarmManager.html#set(int,long,android.app.PendingIntent)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM