只要我知道,"启用AP"的方法没有API,但我可以使用反射来设置它.这就是我的所作所为
wifi_manager = (WifiManager) this.getSystemService(HotSpot_TrisActivity.this.WIFI_SERVICE);
btnEnableAP = (Button)findViewById(R.id.btnEnableAP);
btnEnableAP.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View arg0)
{
// TODO Auto-generated method stub
WifiConfiguration wifi_configuration = null;
wifi_manager.setWifiEnabled(false);
try
{
//USE REFLECTION TO GET METHOD "SetWifiAPEnabled"
Method method=wifi_manager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
method.invoke(wifi_manager, wifi_configuration, true);
}
catch (NoSuchMethodException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IllegalArgumentException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IllegalAccessException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (InvocationTargetException e)
{ …Run Code Online (Sandbox Code Playgroud) 我是android的新手.
我想通过broadcastreceiver(onReceive)接收信息,知道如果用户启用/禁用"Portable Wi-Fi Hotspot" (Settings->Wireless &Networks->Tethering & portable hotspot).
检查此链接
我发现有" android.net.wifi.WIFI_AP_STATE_CHANGED"但它被设置为隐藏.我怎么可以用那个???
提前致谢
在Android的命令行中,有dnsmasq命令。但是所有配置文件(dnsmasq.conf、dnsmasq.pid...)在哪里?
据我尝试创建自己的配置文件并使用以下命令:
dnsmasq --conf-file=the/location/of/my/file
Run Code Online (Sandbox Code Playgroud)
它说:
dnsmasq: 无法打开 pidfile /var/run/dnsmasq.pid: 没有这样的文件或目录
当我创建 pid 文件时,它说:
dnsmasq:无法打开 pidfile dnsmasq.pid:只读文件系统
关于如何控制 dnsmasq(DHCP、DNS 服务器)有什么建议吗?