Skip to content

Commit 3bf552a

Browse files
authored
Merge pull request #4501 from kiwix/Fixes#4500
Fixed: `TetherSettings` was not found on a device.
2 parents 55a599a + 401e471 commit 3bf552a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,21 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
459459
}
460460

461461
private fun launchTetheringSettingsScreen() {
462-
startActivity(
463-
Intent(Intent.ACTION_MAIN, null).apply {
464-
addCategory(Intent.CATEGORY_LAUNCHER)
465-
component = ComponentName("com.android.settings", "com.android.settings.TetherSettings")
466-
flags = Intent.FLAG_ACTIVITY_NEW_TASK
467-
}
468-
)
462+
runCatching {
463+
// Try to open the device's dedicated hotspot/tethering screen.
464+
// Most AOSP-based devices support this explicit Settings component.
465+
startActivity(
466+
Intent(Intent.ACTION_MAIN, null).apply {
467+
addCategory(Intent.CATEGORY_LAUNCHER)
468+
component = ComponentName("com.android.settings", "com.android.settings.TetherSettings")
469+
flags = Intent.FLAG_ACTIVITY_NEW_TASK
470+
}
471+
)
472+
}.onFailure {
473+
// Some OEMs remove or rename the tethering activity, so the direct intent may fail.
474+
// As a fallback, open the Wireless settings screen—this reliably contains the Hotspot option.
475+
startActivity(Intent(Settings.ACTION_WIRELESS_SETTINGS))
476+
}
469477
}
470478

471479
@Suppress("NestedBlockDepth")

0 commit comments

Comments
 (0)