1
votes

I'm trying to launch the Android tethering settings menu from within a program, however it's one of those semi-hidden menus with a slash in its name (com.android.settings/.tether.Tether) and I'm not sure what I should be referring to it as. This is what I've tried so far:

Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings/.tether.Tether");
startActivity(intent);

I've also tried "com.android.settings/" in the setClassName line

However, either way, it says it can't find the class:

I/ActivityManager( 51): Starting activity: Intent { act=android.intent.action.MAIN cmp=com.android.settings/com.android.settings/.tether.Tether } D/AndroidRuntime( 254): Shutting down VM W/dalvikvm( 254): threadid=3: thread exiting with uncaught exception (group=0x4001b188) E/AndroidRuntime( 254): Uncaught handler: thread main exiting due to uncaught exception E/AndroidRuntime( 254): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zzzz.launcher/com.zzzz.launcher.Launcher}: > android.content.ActivityNotFoundException: Unable to find explicit activity class > {com.android.settings/com.android.settings/.tether.Tether}; have you declared this activity in your AndroidManifest.xml?

I have the following activity listed in my manifest file:

<activity android:name="com.android.settings/.tether.Tether" />

(And I've also tried escaping the slash with a backslash, there)

There doesn't appear to be any associated Settings.* value associated with it, so the usual way of launching like the following, wouldn't work:

startActivity(new Intent(Settings.ACTION_TETHER_SETTINGS));

...but even so, I would still like to learn how I can launch it with its classname, because there are other classes with slashes in their names (such as com.android.settings./proxySelector) that I'd like to launch in a similar way.

Cheers,

Paul

(Further stacktrace:)

I/ActivityManager( 59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.zzzz.launcher/.ProxySet bnds=[163,240][237,319] } I/ActivityManager( 59): Start proc com.zzzz.launcher for activity com.zzzz.launcher/.ProxySet: pid=397 uid=10040 gids={1015} I/ActivityManager( 59): Starting activity: Intent { cmp=com.android.settings/.ProxySelector } D/AndroidRuntime( 397): Shutting down VM W/dalvikvm( 397): threadid=1: thread exiting with uncaught exception (group=0x4001d800) E/AndroidRuntime( 397): FATAL EXCEPTION: main E/AndroidRuntime( 397): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zzzz.launcher/com.zzzz.launcher.ProxySet}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.settings/.ProxySelector}; have you declared this activity in your AndroidManifest.xml?

3

3 Answers

7
votes

For Tether settings the correct package/class name is "com.android.settings", "com.android.settings.TetherSettings"

Intent tetherSettings = new Intent();
tetherSettings.setClassName("com.android.settings", "com.android.settings.TetherSettings");
startActivity(tetherSettings);
2
votes

com.android.settings/.tether.Tether is two parts. The first, before the slash, is the package name. The second, after the slash, is the class name. In the contexts you're using them, they must be specified separately.

There are multiple problems with your code:

  1. intent.setClassName("com.android.settings", "com.android.settings/.tether.Tether"); should be intent.setClassName("com.android.settings", ".tether.Tether");

  2. You should not have the activity listed in your manifest; that should be done ONLY if you are implementing the class. It only asked if you have the activity listed in your manifest because it assumed you were implementing it yourself.

-1
votes

How can I activate this setting from code?

I mean how turn on the mobile hotspot from code or calling an intent or class?