开发者

Can An Android Application Be Launched Without a Main Activity?

I have verified that an App does not need a Main Activity, and in fact does not need any activities. Thanks for the responses on this. But here is another question. Is there any way to launch an application without a main activity declared? If the answ开发者_Go百科er is no, then I have a follow up, can the MAIN action be removed from the application at runtime after launch so that the app no longer has a MAIN activity after launch? Or even can the activity itself be entirely removed from the application at runtime if it is no longer needed.


The definition of "the users application list" is "the list of all activities supporting the MAIN action and LAUNCHER category". Hence, if you do not have an activity supporting the MAIN action and LAUNCHER category, nothing from your application will appear in "the users application list".

can the MAIN action be removed from the application at runtime after launch so that the app no longer has a MAIN activity after launch?

You can disable the activity component via PackageManager. This may not immediately remove it from the launcher, as home screens sometimes cache this information. And, it will break any shortcuts the user made to this activity. In general, this is not a recommended technique.

Or even can the activity itself be entirely removed from the application at runtime if it is no longer needed.

No.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜