All Projects → jeziellago → Linkt

jeziellago / Linkt

Licence: MIT license
A lightweight and simple Kotlin library for deep link handling on Android 🔗.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Linkt

Searchwithmybrowser
Open Cortana searches with your default browser.
Stars: ✭ 285 (+182.18%)
Mutual labels:  url, uri
uri
A type to represent, query, and manipulate a Uniform Resource Identifier.
Stars: ✭ 16 (-84.16%)
Mutual labels:  url, uri
Uri Parser
RFC3986/RFC3987 compliant URI parser
Stars: ✭ 342 (+238.61%)
Mutual labels:  url, uri
ocaml-uri
RFC3986 URI parsing library for OCaml
Stars: ✭ 85 (-15.84%)
Mutual labels:  url, uri
Pguri
uri type for PostgreSQL
Stars: ✭ 235 (+132.67%)
Mutual labels:  url, uri
Uri
🌏 Functions for making sense out of URIs in PHP
Stars: ✭ 259 (+156.44%)
Mutual labels:  url, uri
Bidi
Bidirectional URI routing
Stars: ✭ 941 (+831.68%)
Mutual labels:  url, uri
UrlCombine
C# util for combining Url paths. Works similarly to Path.Combine.
Stars: ✭ 23 (-77.23%)
Mutual labels:  url, uri
Scala Uri
Simple scala library for building and parsing URIs
Stars: ✭ 225 (+122.77%)
Mutual labels:  url, uri
Vscode Remote Workspace
Multi protocol support for handling remote files like local ones in Visual Studio Code.
Stars: ✭ 197 (+95.05%)
Mutual labels:  url, uri
uri-query-parser
a parser and a builder to work with URI query string the right way in PHP
Stars: ✭ 38 (-62.38%)
Mutual labels:  url, uri
ST-OpenUri
The ultimate Sublime Text plugin for opening URIs (URLs) in your file.
Stars: ✭ 25 (-75.25%)
Mutual labels:  url, uri
Uri.js
Javascript URL mutation library
Stars: ✭ 6,119 (+5958.42%)
Mutual labels:  url, uri
Tldts
JavaScript Library to work against complex domain names, subdomains and URIs.
Stars: ✭ 151 (+49.5%)
Mutual labels:  url, uri
Uri Components
League URI components objects
Stars: ✭ 244 (+141.58%)
Mutual labels:  url, uri
url-normalize
URL normalization for Python
Stars: ✭ 82 (-18.81%)
Mutual labels:  url, uri
1c http
Подсистема 1С для работы с HTTP
Stars: ✭ 48 (-52.48%)
Mutual labels:  url
relateurl
Create a relative URL with options to minify.
Stars: ✭ 52 (-48.51%)
Mutual labels:  url
link text
Easy to use text widget for Flutter apps, which converts inlined urls into working, clickable links
Stars: ✭ 20 (-80.2%)
Mutual labels:  url
deadlink
💀 Checks and fixes URLs in code and documentation.
Stars: ✭ 105 (+3.96%)
Mutual labels:  url

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].