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...
πŸŽ₯ Android App using Kotlin, MVVM, ViewModel and LiveData, RxJava, Retrofit, REST API, OkHttp, Gson, Glide, Paging library and Material Design. In the app you can see a list of popular movies and additional info about every movie.
πŸŽ₯ Android App using Kotlin, MVVM, ViewModel and LiveData, RxJava, Retrofit, REST API, OkHttp, Gson, Glide, Paging library and Material Design. In the app you can see a list of popular movies and additional info about every movie.

Movies πŸŽ₯ Android App using Kotlin, MVVM, ViewModel and LiveData, RxJava, Retrofit, REST API (https://www.themoviedb.org), OkHttp, Gson, Glide, Paging

A sample Android app which showcases advanced usage of Dagger among other open source libraries.
A sample Android app which showcases advanced usage of Dagger among other open source libraries.

U+2020 A sample Android app which showcases advanced usage of Dagger among other open source libraries. Watch the corresponding talk or view the slide

Movie discovery app showcasing MVP, RxJava, Dagger 2 and Clean Architecture
Movie discovery app showcasing MVP, RxJava, Dagger 2 and Clean Architecture

MovieGuide 🚧 Refactoring in progress πŸ‘·β€β™€οΈ ⛏ πŸ‘· πŸ”§οΈ πŸ‘· πŸ”§ 🚧 Comments and new issues are welcome. πŸ‘ Currently not accepting external PRs that touch

A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Quality-Tools-for-Android 7.5 0.0 L5 Java This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android platform.
Quality-Tools-for-Android 7.5 0.0 L5 Java This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android platform.

Quality Tools for Android This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android pl

[] Port of Jake Wharton's U2020 sample app with use of MVP and Dagger 2
[] Port of Jake Wharton's U2020 sample app with use of MVP and Dagger 2

U+2020-mvp [DEPRECATED] We recomend to try Moxy framework instead of our solution. Port of Jake Wharton's U2020 sample app with use of MVP pattern and

A simple notes app to demo Room + LiveData implementation in Android
A simple notes app to demo Room + LiveData implementation in Android

RoomDb-Sample This is a demo app on how to implement Room persistance library, making use of LiveData in Android app How to implement Room: a SQLite o

A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

How to apply meaningful and delightful motion in a sample Android app
How to apply meaningful and delightful motion in a sample Android app

Applying meaningful motion on Android How to apply meaningful and delightful motion in a sample Android app Read the complete post at https://medium.c

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
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

Kaushik Gopal 7.6k Dec 30, 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 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
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
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
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

Kaushik Gopal 7.6k Dec 29, 2022
Minimal example of how to safely share a file produced by a task in one project, with a task in another project.

How to share files across Gradle subprojects: A minimal example This is the Gradle project: . β”œβ”€β”€ producer β”‚ └── build.gradle.kts β”œβ”€β”€ consumer β”‚ β””

Rob Moore 2 Dec 17, 2021
A sample app showing how to build an app using the MVI architecture pattern.

MVI Example This application was streamed live on Twitch to demonstrate how to build an application using MVI. You can find the VOD here for now: http

Adam McNeilly 46 Jan 2, 2023
A demo app to show how to detect screenshots taken by the user while using the app

Screenshot Detector A demo app to show how to detect screenshots taken by the user while using the app. Blog link Detect Screenshots in Android Screen

Nikit Bhandari 77 Dec 9, 2022