如何通过onclick打开配置便携式Wi-Fi热点设置? [英] how to open configure portable Wi-Fi hotspot setting by onclick?
本文介绍了如何通过onclick打开配置便携式Wi-Fi热点设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何打开以下目录:设置/无线和网络/网络共享和便携式热点/便携式Wi-Fi热点设置/配置便携式Wi-Fi热点/单击按钮? 我想使用onClick方法而不是id方法来实现这一点. 下面是我的代码
how to open the following directory:settings/wireless and networks/Tethering and portable hotspot/portable Wi-Fi hotspot settings/configure portable Wi-Fi hotspot/ on button click? i want to achieve this using onClick method not id method. below is my code
<RadioButton
android:onClick="togglewifi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:checked="true"
android:text="Toggle Wifi" />
public void togglewifi(View view) {
Intent intent = new Intent( );
startActivity(intent);
}
推荐答案
此代码适用于4.2.2
This code works for 4.2.2
final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.TetherSettings");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity( intent);
这篇关于如何通过onclick打开配置便携式Wi-Fi热点设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文