Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何通过onclick打开配置便携式Wi-Fi热点设置?_Android_Settings_Onclicklistener_Buttonclick - Fatal编程技术网

Android 如何通过onclick打开配置便携式Wi-Fi热点设置?

Android 如何通过onclick打开配置便携式Wi-Fi热点设置?,android,settings,onclicklistener,buttonclick,Android,Settings,Onclicklistener,Buttonclick,如何打开以下目录:设置/无线和网络/栓系和便携式热点/便携式Wi-Fi热点设置/配置便携式Wi-Fi热点/打开按钮单击? 我想使用onClick方法而不是id方法来实现这一点。 下面是我的代码 <RadioButton android:onClick="togglewifi" android:layout_width="wrap_content" android:layout_height="wrap_content" and

如何打开以下目录:设置/无线和网络/栓系和便携式热点/便携式Wi-Fi热点设置/配置便携式Wi-Fi热点/打开按钮单击? 我想使用onClick方法而不是id方法来实现这一点。 下面是我的代码

<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);
}

公共无效切换WiFi(视图){
意图=新意图();
星触觉(意向);
}
使用“按钮”而不是“单选按钮”

在布局中,请尝试以下操作:

<Button 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_send"
    android:onClick="togglewifi" />

此代码适用于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);

如果有人像我一样在安卓8上登陆,我就用这个打开设置热点页面本身

public static final String SETTINGS_PACKAGE = "com.android.settings";
public static final String HOTSPOT_SETTINGS_CLASS = "com.android.settings.Settings$TetherWifiSettingsActivity";

private void launchHotspotSettings(){
    Intent intent = new Intent(Intent.ACTION_MAIN, null);
    ComponentName componentName = new ComponentName(SETTINGS_PACKAGE, HOTSPOT_SETTINGS_CLASS);
    intent.setComponent(componentName);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}
在我的设备上工作。 让我知道它是否对你有效。 经过一点研究后,我意识到这类产品会随着设备品牌的不同而变化。 对于三星,使用

public static final String HOTSPOT_SETTINGS_CLASS = "com.android.settings.Settings$WifiApSettingsActivity";

顺便说一句,@Drew answer在Android 8上仍然有效。

在Java中激活栓系:

private void activeTethering(){
    Intent tetherSettings = new Intent();
    tetherSettings.setClassName("com.android.settings", "com.android.settings.TetherSettings");

    startActivity(tetherSettings);
}
在科特林:

private fun activeTethering(){
    val tetherSettings = new Intent().apply {
        setClassName("com.android.settings", "com.android.settings.TetherSettings")
    }

    startActivity(tetherSettings);
}

jeetu,我不想打开wifi设置,我想打开“配置便携式Wi-Fi热点”。我需要转到热点设置。因此,我可以在7.1.1上更改hotspot passwordWorks,拯救我的生命。这将打开Tethering屏幕。是否有其他方法仅打开WiFi热点屏幕?我知道这是可能的,因为SHAREit就是这么做的。这对我来说也是有效的吗?有没有可能在热点上设置而不是设置热点?嗨,多斯基,你是怎么得到这些信息的?我有一个三星的例子,但我也需要索尼,华为等。。。如何在这些手机上找到这些定制活动的“路径”?谢谢再见。我基本上检查了日志。当您检查日志时,每个新页面都会告诉您打开了哪些活动。我可以在信息日志下看到我的设置,大多数情况下它都带有标签ActivityManager,或者你可以只搜索设置或com.android.Settings.Settings,然后尝试导航到你想要的页面。你应该看看这样的东西<代码>09-12 19:19:39.345 805-858/?I/ActivityManager:displated com.android.settings/.settings$wifisettingsavity:+603ms如果您有问题,请告诉我。注意:设备必须连接到设备并处于调试模式。此外,如果你能成功地编译列表,请帮助我为它提供一个重要的url。我身边没有太多设备。嗨,多斯基,我试过你说的,但我看不到完整的信息,试过三星S9 y只能看到:I/ActivityManager:displated com.android.settings/.SubSettings:+430ms是否有任何选项我必须激活才能看到更清晰的“SubSettings”?谢谢您是否尝试导航到热点设置活动本身?您需要导航到所需的活动,然后检查记录的内容。
private fun activeTethering(){
    val tetherSettings = new Intent().apply {
        setClassName("com.android.settings", "com.android.settings.TetherSettings")
    }

    startActivity(tetherSettings);
}