Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to open configure portable Wi-Fi hotspot setting by onclick?

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);
}
like image 926
Anonymous Avatar asked Nov 30 '22 02:11

Anonymous


1 Answers

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);
like image 198
Drew Avatar answered Dec 05 '22 02:12

Drew