Aada
Aada

Reputation: 1640

In Android Activity's intent action?

If an activity 'A' declares two actions in its manifest. and another activity named as 'B' starts the activity A by setting one of its action.

Is it possible for activity A to know which action is been set for calling ?

Activity B:

    Intent intent=new Intent(this,secondactovity.class);
    intent.setAction("lets.open.via.dashboard");
    startActivity(intent);

Activity A Manifest file:

  <activity android:name="com.example.testing.secondactovity">
       <intent-filter >
           <action android:name="lets.open.via.home"/>
           <action android:name="lets.open.via.you"/>
       </intent-filter>
   </activity>

Upvotes: 0

Views: 68

Answers (2)

Aada
Aada

Reputation: 1640

Hi ya figured it out ---

 if(getIntent().getAction().equalsIgnoreCase("lets.open.via.home")){
        Toast.makeText(this,"Done",Toast.LENGTH_LONG).show();
    }
    else {
        Toast.makeText(this,"oops",Toast.LENGTH_LONG).show();
    }

Thanks everyone

Upvotes: 0

Paul Burke
Paul Burke

Reputation: 25584

Sure, in Activity A simply call:

getIntent().getAction();

Upvotes: 2

Related Questions