Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to open tethering settings #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ AndroidOpenSettings.locationSourceSettings()
// Open wireless settings menu
AndroidOpenSettings.wirelessSettings()

// Open tethering settings menu
AndroidOpenSettings.tetheringSettings()

// Open airplane mode settings menu
AndroidOpenSettings.airplaneModeSettings()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void generalSettings() {
reactContext.startActivity(intent);
}
}

@ReactMethod
public void homeSettings() {
Intent intent = new Intent(Settings.ACTION_HOME_SETTINGS);
Expand Down Expand Up @@ -84,6 +84,17 @@ public void wirelessSettings() {
}
}

@ReactMethod
public void tetheringSettings() {
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.TetherSettings");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
if (intent.resolveActivity(reactContext.getPackageManager()) != null) {
reactContext.startActivity(intent);
}
}

@ReactMethod
public void airplaneModeSettings() {
Intent intent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS);
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare module "react-native-android-open-settings" {
const wifiSettings: () => void;
const locationSourceSettings: () => void;
const wirelessSettings: () => void;
const tetheringSettings: () => void;
const airplaneModeSettings: () => void;
const apnSettings: () => void;
const bluetoothSettings: () => void;
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const locationSourceSettings = () => RNAndroidOpenSettings.locationSourceSetting

const wirelessSettings = () => RNAndroidOpenSettings.wirelessSettings()

const tetheringSettings = () => RNAndroidOpenSettings.tetheringSettings()

const airplaneModeSettings = () => RNAndroidOpenSettings.airplaneModeSettings()

const apnSettings = () => RNAndroidOpenSettings.apnSettings()
Expand Down Expand Up @@ -49,6 +51,7 @@ module.exports = {
wifiSettings,
locationSourceSettings,
wirelessSettings,
tetheringSettings,
airplaneModeSettings,
apnSettings,
bluetoothSettings,
Expand Down