android)我可以设置一个安装后立即运行的默认活动吗
在我的应用程序中,有两个活动,我想在安装后将 Activity1 设为启动活动。 但现在 RUN 按钮(在安装 packgae 后立即显示)被禁用。
下面是清单文件。谢谢。
<activity ...1>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity ...2>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</activity>
in my app, there is two activity and i want to make activity1 to the starting activity after installation.
But now the RUN button (is showed right after packgae installing) is disabled.
below is the manifest file. thanks.
<activity ...1>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity ...2>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</activity>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有活动“安装后立即运行”。用户必须从启动器启动它。
不,不是。那甚至不是有效的 XML。
另请注意,您的第三个
无效。您不仅缺少任何类别(活动至少需要DEFAULT
),而且ACTION_POWER_CONNECTED
和ACTION_POWER_DISCONNECTED
都不是活动操作。我猜你真的想问:“我有两个活动,都描述为 ACTION_MAIN/CATEGORY_LAUNCHER,现在“运行”按钮不起作用 - 我能做什么?答案是“要么从其中之一中删除 ACTION_MAIN/CATEGORY_LAUNCHER
,要么将两者之一标记为禁用(android:enabled="false"
) 并稍后使用启用它PackageManager
。”No activity "runs right after installing". The user has to launch it from the launcher.
No, it is not. That is not even valid XML.
Also, note that your third
<intent-filter>
is invalid. Not only are you missing any category (you need at leastDEFAULT
for activities), butACTION_POWER_CONNECTED
andACTION_POWER_DISCONNECTED
are not activity actions.I am going to take a guess that you really mean to ask: "I have two activities, both described as ACTION_MAIN/CATEGORY_LAUNCHER, and now the Run button does not work -- what can I do?" The answer would be "either remove the ACTION_MAIN/CATEGORY_LAUNCHER
<intent-filter>
from one of them, or mark one of the two as disabled (android:enabled="false"
) and enable it later on usingPackageManager
."我认为问题是第二个:
您不应该将 2 个活动标记为 MAIN 和 LAUNCHER 活动。
尝试在 Activity2 中删除它。
查看: http://developer.android.com/reference/android/content/ Intent.html 讨论了intentfilter。
I think the problem is the second:
You shouldn't have 2 activities flagged as the MAIN and LAUNCHER activity.
Try removing it within activity2.
Check out: http://developer.android.com/reference/android/content/Intent.html the intentfilter s are discussed.