近期在用am start 的时候,如果指定打开Activity的类则需要加上 [-n <COMPONENT>]
其中COMPONENT 不同于在代码中指定的类名。
举例说明:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setComponent(new ComponentName("com.test", "com.test.TestActivity"));这其中指定activity可直接写入com.test.TestActivity
使用am start
String s = "am start -n "+new ComponentName("com.test", "com.test.TestActivity").flattenToShortString();只有这样拼接才能正确使用。最终s打印出的值为
am start -n com.test/.TestActivity
本文详细介绍了如何使用amstart命令来启动指定的Activity,并给出了具体的示例代码。通过对比Intent对象设置组件名称的方式,展示了正确的命令行参数组合方法。
7641

被折叠的 条评论
为什么被折叠?



