删除活动后作为默认启动器如何在android中启动活动 [英] after removing activity as default launcher how to start activity in android

查看:74
本文介绍了删除活动后作为默认启动器如何在android中启动活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我需要帮助我想知道删除活动后作为默认启动器如何启动该活动

Hi i need help i want to know after removing activity as default launcher how to start that activity

推荐答案

这是不可能的。

因为当您将活动类别删除为Launcher时,Android系统将无法了解在请求打开应用程序时需要启动哪个活动。

因此你必须在Manifest.xml文件中指定Launcher活动,就像这样,

That is impossible.
Because as you removed the category of activity as Launcher, the Android system won't be able to understand which activity need to be started when application is requested to be opened.
Therefore you must specify Launcher activity in Manifest.xml file, like this,
<activity android:name=".ExampleActivity" android:icon="@drawable/app_icon">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>



要解决此问题,您需要使用明确意图

您不希望其他应用程序可用的活动应该没有意图过滤器,您可以启动他们自己使用明确的意图。



阅读此意图 [ ^ ]


To overcome this, you need to use Explicit Intents,
Activities that you don't want to make available to other applications should have no intent filters and you can start them yourself using explicit intents.

Read this Intent[^]

Quote:

显式意图指定按名称开始的组件(完全限定的类名)。您通常会使用显式意图在您自己的应用中启动组件,因为您知道要启动的活动或服务的类名。例如,启动一个新活动以响应用户操作或启动服务以在后台下载文件。

Explicit intents specify the component to start by name (the fully-qualified class name). You'll typically use an explicit intent to start a component in your own app, because you know the class name of the activity or service you want to start. For example, start a new activity in response to a user action or start a service to download a file in the background.



例如,


for example,

Intent intent = new Intent(this, SignInActivity.class);
startActivity(intent);





-KR



-KR


这篇关于删除活动后作为默认启动器如何在android中启动活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆