0

I have an activity that has this intent in the manifest:

<activity
    android:name=".view.MainActivity"
    android:launchMode="singleTask"
    android:screenOrientation="portrait">
    <intent-filter>
        <data android:scheme="http" android:host="mc8.eu"/>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

If I receive an SMS with this scheme, the activity correctly is opened if I click the url.

What I need is to understand if the activity is opened by the intent or by another app activity.

I tried with this code:

@Override
protected void onResume() {
    super.onResume();

    Uri ref = getReferrer();
}

But getReferrer always returns null.

Giacomo M
  • 4,450
  • 7
  • 28
  • 57

1 Answers1

0

Once the system starts your activity through an intent filter, you can use data provided by the Intent to determine what you need to render. Call the getData() and getAction() methods to retrieve the data and action associated with the incoming Intent

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent intent = getIntent();
    String action = intent.getAction();
    Uri data = intent.getData();
}

Android Documentation

Sachin Kasaraddi
  • 597
  • 5
  • 12