Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix null Uri data = intent.getData() in Android

I want Open this link in my application, not open in browser. for this job i want use DeepLink.
But when start application, show me null for URI.

My link : Link

I write this code in manifest :

<activity
    android:name=".Activities.PostShow_page"
    android:screenOrientation="portrait"
    android:theme="@style/AppThemeWithStatus">

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="www.kolony.ir"
            android:scheme="http" />

        <data
            android:host="kolony.ir"
            android:scheme="http" />

    </intent-filter>

</activity>

Activity codes:

// Deep Linking
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
Log.e("Deep", "Link : " + data);

but when running application, in LogCat show this : Link : null

How can i fix null for this URI and show uri in logCat ?


1 Answers

Simply instead of using getIntent() use intent parameter of onNewIntent(Intent intent) event handler

like image 55
mehrdad seyrafi Avatar answered Mar 15 '26 09:03

mehrdad seyrafi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!