【发布时间】:2011-06-20 03:52:48
【问题描述】:
我正在尝试从程序中启动 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):开始活动:Intent { act=android.intent.action.MAIN cmp=com.android.settings/com.android.settings/.tether.Tether } D/AndroidRuntime(254):关闭虚拟机 W/dalvikvm(254):threadid=3:线程退出未捕获异常(组=0x4001b188) E/AndroidRuntime(254):未捕获的处理程序:线程主因未捕获的异常而退出 E/AndroidRuntime(254):java.lang.RuntimeException:无法启动活动 ComponentInfo{com.zzzz.launcher/com.zzzz.launcher.Launcher}:> android.content.ActivityNotFoundException:无法找到显式活动类 > {com .android.settings/com.android.settings/.tether.Tether};您是否在 AndroidManifest.xml 中声明了此活动?
我的清单文件中列出了以下活动:
<activity android:name="com.android.settings/.tether.Tether" />
(我也尝试过用反斜杠转义斜线)
似乎没有任何关联的 Settings.* 值与之关联,因此通常的启动方式如下所示,不起作用:
startActivity(new Intent(Settings.ACTION_TETHER_SETTINGS));
...但即便如此,我仍然想了解如何使用其类名启动它,因为我还有其他名称中带有斜杠的类(例如 com.android.settings./proxySelector)想以类似的方式启动。
干杯,
保罗
(进一步的堆栈跟踪:)
I/ActivityManager(59):开始活动: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):为活动 com.zzzz.launcher/.ProxySet 启动 proc com.zzzz.launcher:pid=397 uid=10040 gids={1015} I/ActivityManager(59):开始活动:Intent { cmp=com.android.settings/.ProxySelector } D/AndroidRuntime(397):关闭虚拟机 W/dalvikvm(397):threadid=1:线程退出未捕获异常(组=0x4001d800) E/AndroidRuntime(397):致命异常:主要 E/AndroidRuntime(397):java.lang.RuntimeException:无法启动活动 ComponentInfo{com.zzzz.launcher/com.zzzz.launcher.ProxySet}:android.content.ActivityNotFoundException:找不到显式活动类 {com.android .settings/.ProxySelector};您是否在 AndroidManifest.xml 中声明了此活动?
【问题讨论】:
标签: android android-activity android-intent