android - 从程序中启动隐藏的 Android 设置 Activity

我正在尝试从程序中启动 Android 网络共享设置菜单,但它是名称中带有斜杠的半隐藏菜单之一 (com.android.settings/.tether.Tether),我正在不确定我应该将其称为什么。到目前为止,这是我尝试过的:

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

我还在 setClassName 行中尝试了“com.android.settings/”

但是,无论哪种方式,它都表示找不到类:

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?

我的 list 文件中列出了以下 Activity :

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

(我也试过用反斜杠转义斜杠)

似乎没有任何关联的设置。* 与之关联的值,因此像下面这样的通常启动方式是行不通的:

startActivity(new Intent(Settings.ACTION_TETHER_SETTINGS));

...但即便如此,我仍然想了解如何使用它的类名启动它,因为还有其他名称中带有斜杠的类(例如 com.android.settings./proxySelector)我我想以类似的方式发布。

干杯,

保罗

(进一步的堆栈跟踪:)

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?

最佳答案

对于 Tether 设置,正确的包/类名称是“com.android.settings”、“com.android.settings.TetherSettings”

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

https://stackoverflow.com/questions/6406668/

相关文章:

oracle - 在 Oracle 中使用索引反转字符串

iphone - UITableView 中图像的圆角矩形/圆角

java - 为什么我们不能将实例变量传递给父类(super class)构造函数?

jquery - 你如何使用 jquery 将一个下拉列表的选项复制到另一个下拉列表

php - 如何在 PHP 中设置环境变量?

visual-studio - Visual Studio : Debugging Chrome w

php - 使用php获取字符串的一部分

wpf - TimeSpan 的 MultiBinding StringFormat

perl - perl中散列的散列问题

winforms - 使用 Windows 窗体创建棋盘