TheJadav

Deeplink in android with custom URI or callback url

This is commonly used technique for Oauth in many applications. This is also useful to forcing user to use application.

We are just covering how to handle deeplink in android application.

This is commonly used technique for Oauth in many applications. This is also useful to forcing user to use application.

We are just covering how to handle deeplink in android application.

Implement Custom Uri deeplink

Add following lines in Menifest.xml file

            <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:scheme="example"/>
            </intent-filter>

code explanation:

  1. “category.Browsable” is to tell system this app has browsable content
  2. “action.view” is to tell system this activity can view data
  3. “data” tag to describe scheme and host

Here my code opens app when user click on link like this : “example://myapp?show=true”, Above code is only checking scheme that is “example” and open app. But we can also specify host is my case it is “myapp”, which further defines specific host content only.
Now our app is opened, but sometime we might need some condition specific features after app opens from deep link. In my case I am showing dialog if show=true. To get data from uri we need to parse uri and its parameters.
Here I have showed how can we get uri in Activity file:

  
  override fun onResume() {
        super.onResume()
        val data  = intent.data
        val success = data?.getQueryParameter("show")
        
        /****/
    }
  
  

Check here I got uri in intent and also get query parameter from uri,
Note : always add new intent-filter when defining in Manifest.xml file.

Keep smiling & Learn something

Share this content:

Share:

More Posts

Introduction to Kotlin: A Versatile and Modern Programming Language

Kotlin, a versatile and modern programming language, offers developers a concise, safe, and interoperable coding experience. With features like null safety, extension functions, and coroutines, Kotlin enhances productivity and readability, making it an attractive choice for Android development and beyond. Whether you’re new to programming or an experienced developer, exploring Kotlin opens up a world of possibilities for building robust and expressive applications.

Mastering the Android Activity Lifecycle: A Comprehensive Guide

The Android Activity Lifecycle is a fundamental concept for Android developers. It defines how an Activity behaves during its lifecycle, from creation to destruction. Understanding the Activity Lifecycle is crucial for managing resources efficiently and delivering a smooth user experience. In this blog post, we’ll briefly introduce the different states an Activity can be in and the main callback methods associated with each state. Let’s dive in and explore this important aspect of Android app development!

Table of Contents

Send Us A Message