pau*_*888 0 android android-intent android-activity
我正试图从一个程序中启动Android网络共享设置菜单,但它是其名称中包含斜杠的半隐藏菜单之一(com.android.settings/.tether.Tether),我不知道是什么我应该把它称为.这是我到目前为止所尝试的:
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings/.tether.Tether");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
我还尝试了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):关闭VM W/dalvikvm(254):threadid = 3:线程退出,未捕获异常(group = 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" />
Run Code Online (Sandbox Code Playgroud)
(而且我也尝试用反斜杠逃避斜线,那里)
似乎没有任何关联的Settings.*值与之关联,因此通常的启动方式如下所示,不起作用:
startActivity(new Intent(Settings.ACTION_TETHER_SETTINGS));
Run Code Online (Sandbox Code Playgroud)
...但即便如此,我仍然想学习如何使用它的类名启动它,因为其他类的名称中包含斜杠(例如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):启动proc com.zzzz.launcher for activity com.zzzz.launcher/.ProxySet:pid = 397 uid = 10040 gids = {1015} I/ActivityManager(59):启动活动: Intent {cmp = com.android.settings/.ProxySelector} D/AndroidRuntime(397):关闭VM W/dalvikvm(397):threadid = 1:线程退出,未捕获异常(组= 0x4001d800)E/AndroidRuntime(397) :FATAL EXCEPTION:main E/AndroidRuntime(397):java.lang.RuntimeException:无法启动活动ComponentInfo {com.zzzz.launcher/com.zzzz.launcher.ProxySet}:android.content.ActivityNotFoundException:无法找到显式活动class {com.android.settings/.ProxySelector}; 你有没有在AndroidManifest.xml中声明这个活动?
小智 6
对于Tether设置,正确的包/类名称是"com.android.settings","com.android.settings.TetherSettings"
Intent tetherSettings = new Intent();
tetherSettings.setClassName("com.android.settings", "com.android.settings.TetherSettings");
startActivity(tetherSettings);
Run Code Online (Sandbox Code Playgroud)