• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created almost 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A lightweight and simple Kotlin library for deep link handling on Android ๐Ÿ”—.

Linkt

A lightweight and simple kotlin library for deep link handling on Android.

Setup

Configure root build.gradle (jitpack.io):

allprojects {  
    repositories {  
        ...  
        maven { url 'https://jitpack.io' }  
    }  
}  

Add Linkt to your project build.gradle:

dependencies {
  implementation 'com.github.jeziellago:Linkt:TAG'
}
  1. Create your DeepLinkModule and register deep links:
class MyDeepLinkModule : DeepLinkModule {

    override fun load() {
        deepLinkOf(
            "linkt://sample",
            "linkt://sample/{userId}/{userName}"
        ) { context, bundle ->
            Intent(context, MainActivity::class.java)
                .apply { putExtras(bundle) }
        }
    }
}

In multi-module projects you should have one or more DeepLinkModule`s.

  1. Register your modules into Application#onCreate, with DeepLinkLoader#setup:
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        DeepLinkLoader.setup(MyDeepLinkModule())
    }
}
  1. Create the DeepLinkActivity (or use yours if already exists), and call DeepLinkLoader#loadFrom:
class DeepLinkActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // resolve deeplink
        DeepLinkLoader.loadFrom(this)
    }
}

Don't forget to configure AndroidManifest.xml (required for Android deep links):

<activity
    android:name="org.linkt.DeepLinkActivity"
    android:theme="@android:style/Theme.NoDisplay">
    <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="mycompany" />
    </intent-filter>
</activity>

How to get data from deeplink?

In your activity, you can get path parameters and query values as String from intent.extras:

Path parameters

  • Template linkt://sample/{userId}/{userName}
  • Received: linkt://sample/9999/Jose
// get path parameters
val userId = intent.extras.getString("userId")
val userId = intent.extras.getString("userName")

Query parameters

  • Template: linkt://sample
  • Received linkt://sample?subject=Linkt&name=Sample
// get query parameters
val subject = intent.extras.getString("subject")
val name = intent.extras.getString("name")

Path + query parameters

  • Template linkt://sample/{userId}/{userName}
  • Received linkt://sample/999/Jose?subject=Linkt&name=Sample
// get path parameters
val userId = intent.extras.getString("userId")
val userId = intent.extras.getString("userName")
// get query parameters
val subject = intent.extras.getString("subject")
val name = intent.extras.getString("name")

Licence

Copyright (c) 2021 Jeziel Lago

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

compose-markdown

Markdown Text for Android Jetpack Compose ๐Ÿ“‹.
Kotlin
326
star
2

FlowNav

Annotation processor that provides better navigation on android multi-modules projects ๐Ÿ›ณ.
Kotlin
135
star
3

image-minifier

Minifier is a lightweight android library for image resizing, format changing and quality focusing in reduce file size ๐Ÿ–ผ.
Kotlin
65
star
4

kachej

An alternative to building cache easily backed by Kotlin coroutines ๐Ÿ“ฆ.
Kotlin
25
star
5

SecBox

Script Box for Android Reverse Engineering
Python
24
star
6

multinavcompose

Android multi-module navigation built on top of Jetpack Navigation Compose
Kotlin
21
star
7

AppCloneDetector

Kill app if it is running under a cloned environment in Android device.
Kotlin
11
star
8

CoroutinesFlowExt

Reactive components with Kotlin Flow ๐Ÿ› 
Kotlin
6
star
9

dojo-flow-with-room

Kotlin
5
star
10

mlkit-face-detection

Android face detection example with ML Kit
Kotlin
5
star
11

jni-android-sha-256

Android JNI example for get ANDROID_ID and generate SHA-256 hash using C/C++.
C++
4
star
12

rustium

Medium rss feed api built with Rust (study project).
Rust
4
star
13

dojo-coroutines-2

Kotlin
4
star
14

explore-event-driven-arch-android

Study project
Kotlin
3
star
15

rust-url-shortener

Url shortener written in Rust
Rust
3
star
16

ktxsafe

Kotlin functions and extensions to do safe unwrap and extract values.
Kotlin
3
star
17

android-image-kit

Open-source library for image processing in Android.
Kotlin
3
star
18

GoogleFilesFinder

A Google Files Finder in python
Python
2
star
19

dojos-coroutines

Kotlin
2
star
20

android-reverse-shell-example

Android reverse shell example with native library.
CMake
2
star
21

minimal-android-ci

Minimal container for android builds.
Dockerfile
2
star
22

hello-koin

Sample project with Koin 2.0 and JUnit Test
Kotlin
1
star
23

jeziellago

1
star
24

dojo-kotlin-file-watcher

Kotlin
1
star
25

coroutines-dojo-3

Kotlin
1
star
26

talk-android-reverse-engeneering

Kotlin
1
star
27

injection-with-locator

Basic Service locator implementation solving dependency injection on Android.
Kotlin
1
star
28

kotlin-primitive-map

A simple solution to create maps of primitive values in Kotlin.
Kotlin
1
star
29

ideas-kotlin-problems

Kotlin
1
star
30

algorithms

Kotlin
1
star