简体   繁体   English

我的Android应用程序中可以有多个getIntent()方法吗?

[英]Can i have Multiple getIntent() methods in my android App?

I want to receive an intent from my applications first activity to second and also from some other application in the same (Second activity). 我希望从我的应用程序第一个活动到第二个活动以及同一个活动中的其他应用程序(第二个活动)收到一个意图。

Can it be done? 可以吗?

The Intent represents an app's "intent to do something.", and every Activity is invoked by an Intent. Intent代表一个应用程序“意图做某事。”,每个Activity都由Intent调用。

Your SecondActivity will be started with you start an implicit or explicit intent. 您将在启动隐式或显式意图时启动SecondActivity

You wanna your SecondActivity to be started from your Activity or from other app, you need to define a custom Action for this. 您希望从您的Activity或其他应用程序启动SecondActivity,您需要为此定义自定义操作

<activity android:name=".SecondActivity" >  
<intent-filter>
    <action android:name="com.example.DO_SOME_ACTION" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

You be able to start your Activity from any application like this : 您可以从以下任何应用程序启动您的活动:

Intent intent = new Intent();
intent.setAction("com.example.DO_SOME_ACTION");
startActivity(intent);

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

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