Example app for shortcuts

Overview

Android Shortcuts

Example app for shortcuts in design library v25

Demo

Demo 1 Demo 1

Manifest

Add meta-data before </activity> tag in Manifest.xml

<meta-data android:name="android.app.shortcuts"
    android:resource="@xml/shortcuts" />

Add Shortcut

To add or edit a new shotcut, go to /res/xml/shortcuts.xml :

<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
    <shortcut
        android:shortcutId="shortcut1"
        android:enabled="true"
        android:icon="@drawable/ic_directions_run_black_24dp"
        android:shortcutShortLabel="@string/shortcut1"
        android:shortcutLongLabel="@string/shortcut1_long"
        android:shortcutDisabledMessage="@string/shortcut1_disabled">
        <intent
            android:action="custom_action"
            android:targetPackage="com.pamir.shortcuts"
            android:targetClass="com.pamir.shortcuts.MainActivity" />
    </shortcut>
</shortcuts>

Handle Actions

To handle shortcuts, just add new constant:

private final static String CUSTOM_ACTION = "custom_action";

and check the intent for custom action :

switch (getIntent().getAction()){
    case CUSTOM_ACTION:
        textView.setText(CUSTOM_ACTION);
        break;
    default:
        break;
}
You might also like...
Learning RxJava for Android by example

Learning RxJava for Android by example This is a repository with real-world useful examples of using RxJava with Android. It usually will be in a cons

Simple blockchain example written in Kotlin

Blockchain in Kotlin This is a plain example how Cryptographic blockchains work by constructing a blockchain containing three blocks. Once constructed

Example of a multimodule project following SOLID principles and MVVM, Hilt, Room, coroutines and testing.
Example of a multimodule project following SOLID principles and MVVM, Hilt, Room, coroutines and testing.

MarvelCharacters David Ferrándiz Features Retrieve Marvel’s characters and show them in a grid. See more information about the character in a new scre

Weather application example with Android Architecture components and Clean Architecture

Weather application example with Android Architecture components and Clean Architecture Weather app that shows how to architect an android app in a cl

This is an example for running a Python library (mishkal) in Android using chaquopy
This is an example for running a Python library (mishkal) in Android using chaquopy

chaquopy-mishkal This is an example for running a Python library (mishkal) in Android using chaquopy Code All the code that has been added to run the

Movies-db-example - Sample Android application that loads movies data from a remote server

Movies Application Sample Android application that loads movies data from a remo

vBulletin 2FA BruteForce Example Kotlin Script on bruteforcing 2FA for vBulletin 4.x

vBulletin 2FA BruteForce Example Kotlin Script on bruteforcing 2FA for vBulletin 4.x

The Movie Database Example
The Movie Database Example

This is a sample application that build with combine use Clean Architecture framework and Movie Database API for request and showing the information

A small RPG example for a YouTube tutorial series using Kotlin, LibGDX, LibKTX and GDX-AI.
A small RPG example for a YouTube tutorial series using Kotlin, LibGDX, LibKTX and GDX-AI.

Mystic Woods A libGDX project generated with gdx-liftoff. This project was generated with a Kotlin project template that includes Kotlin application l

Comments
  • How to judge whether the application is alive or not to open different Activity?

    How to judge whether the application is alive or not to open different Activity?

    How to judge whether the application is alive or not to open different Activity?

    Example: The final page to reach is search

    A: Application alive step 1 MainActivity 2 SearchActivity

    B: Application dead step 1 SplashActivity 2 MainActivity 3 SearchActivity

    However, manifest.xml or dynamic shortcuts can only specify one TargetClass

    Thank you very much ~

    opened by 13120241790 0
Owner
Pamir Cevikogullari
Android Developer (Kotlin & Java)
Pamir Cevikogullari
Github-Api-Pagination-Example - Pagination 3 Example using Github Api

Github-Api-Pagination Pagination 3 Example using Github Api Tech Stack 100% Kotl

Anggoro Beno Lukito 2 Aug 22, 2022
App Tragos: a clean architecture app example

CocktailApp This is a clean architecture app example built with Coroutines MVVM Extension Functions Dagger Hilt Retrofit Room Navigation Components Ca

Axel-Aranibar 1 Jun 23, 2022
Weather app : Jetpack Compose Clean Architecture Example

Weather app - Jetpack Compose Clean Architecture Example Weather app is an example for show current weather from World Cities, built with Jetpack Comp

Bach 20 Nov 21, 2022
Slack app example for Heroku deployment, written in Kotlin, using Bolt framework.

slack-kotlin-heroku-example Slack app example for Heroku deployment, written in Kotlin, using Bolt framework. You need to configure your Slack app to

null 0 Dec 25, 2021
Example of Android project showing integration with Kotlin and Dagger 2

kotlin-dagger-example This project demonstrate how to setup an Android Project with Kotlin and Dagger 2. It's based on Dagger 2 example ##Known issues

Damian Petla 533 Nov 11, 2022
The example Android project of animated menu items in toolbar

Android Animated Menu Items The example Android project of animated menu items in toolbar. Thanks Srikant Shetty for idea of this animation. Cut: Copy

Ilya Fomenko 922 Nov 23, 2022
This is a simple example of Aspect Oriented Programming in Android

Android-AOPExample This is a simple example of Aspect Oriented Programming in Android as part of a blog post I have written. The idea was to measure h

Fernando Cejas 422 Nov 25, 2022
Basic example of using ItemTouchHelper to add drag & drop and swipe-to-dismiss to RecyclerView.

Another drag and swipe library? This project is an example of basic drag & drop and swipe-to-dismiss with RecyclerView using ItemTouchHelper. It corre

Paul Burke 2.5k Dec 24, 2022
This repo contains example code for O'Reilly's "Programming Android" by Zigured Mednieks, Laird Dornin, Blake Meike and Masumi Nakamura

This repo contains working code for the example in O'Reilly's _Programming Android, 2nd Edition_; Mednieks, Dornin, Meike, Nakamura (http://shop.orei

G. Blake Meike 214 Nov 25, 2022
This repo contains example code for O'Reilly's "Programming Android" by Zigured Mednieks, Laird Dornin, Blake Meike and Masumi Nakamura

This repo contains working code for the example in O'Reilly's _Programming Android, 2nd Edition_; Mednieks, Dornin, Meike, Nakamura (http://shop.orei

G. Blake Meike 165 Nov 11, 2022