简体   繁体   English

Android:使用Intent或intent-filter启动活动

[英]Android: start an activity with an Intent or an intent-filter

I always start activities with Intents, but in the book which I'm reading an activity is started with an action parameter: Not in this classical way 我总是用Intents开始活动,但是在我正在阅读的书中,一个活动是以一个动作参数开始的:不是以这种经典的方式

Intent intent = new Intent(this,ActivityResult.class);

But in this way: 但是这样:

String PICK_BUS_ACTION = "com.example.utente.decompilare" + ".action.PICK_BUS_ACTION";
Intent intent = new Intent(PICK_BUS_ACTION);

And in the manifest there is an intent-filter: 在清单中有一个intent-filter:

<activity android:name=".ActivityResult">
        <intent-filter>
            <action android:name="com.example.utente.decompilare.action.PICK_BUS_ACTION" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

I tried both the ways but I didn't find differences. 我尝试了两种方式,但没有发现差异。 What is better? 什么是更好的? What is the difference? 有什么区别?

第二个用于启动另一个应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM