Giter Club home page Giter Club logo

android-shortcuts's Introduction

android-shortcuts

Shortcuts that lands you to an specific activity or fragment to perform a task from outside of an application.Long tap an app to see a list of shortcuts.

Availability

App Shortcuts are available from API Level 25 (Android 7.1) and above.

Limitation

Shortcuts are limited to 4 in number.

Types

We have 3 types of shortcuts available which we can use according to the condition or needs of an application

  • Static Shortcuts
  • Dynamic Shortcuts
  • Pinned Shortcuts

Read more on the docs - https://developer.android.com/guide/topics/ui/shortcuts/creating-shortcuts

Why I'm making this Repo ?

After searching the topics based Android Shortcuts,I didn't find a complete and clear solution according to my needs.And from reading most of them I'm making this one as a solution to the problem that most of the people face or talk about/ask for help in the forums which is "How can I go to Fragment using Shortcut ?" Well, fragments are attached to an activity.

So to solve this you will need an Activity (Must be in an IntentFilter with intent action MAIN android.intent.action.MAIN and category must be the LAUNCHER android.intent.category.LAUNCHER) i.e your LAUNCHER Activity.

Static Shortcuts

These are the shortcuts that are created only one time and are static in nature (cannot be changed).To make static shortcuts,you need to make a file in res/xml/shortcuts.xml and then link this file in your AndroidManiest.xml under your LAUNCHER Activity.There are more attributes and related things to static shortcuts,try to read the docs too.

   <!-- AndroidManifest.xml -->
   <activity
            android:name=".OnBoardingActivity"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoTitleBar"
            tools:ignore="LockedOrientationActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
     <!-- Here you have linked the static shortcuts.xml file -->
            <meta-data android:name="android.app.shortcuts"
                android:resource="@xml/shortcuts" />
        </activity>

Dynamic Shortcuts

Dynamic shortcuts are created when the app runs,it can perform the most recent task like calling or messaging and something unique like this.Due to dynamic in nature,dynamic shortcuts can be updated,deleted,disabled or even it can be removed easily you are fully responisbe for it,there's more you can find about dynamic shortcuts,try to read the docs too.To make dynamic shortcut do some change in the AndroidManiest.xml

   <!-- AndroidManifest.xml -->
<activity
            android:name=".OnBoardingActivity"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoTitleBar"
            tools:ignore="LockedOrientationActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
           <activity
            android:name=".MainActivity"
            android:exported="true"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoActionBar"
            tools:ignore="LockedOrientationActivity">
        </activity>

Note : The "exported" attribute describes whether or not someone else can be allowed to use it even that or other app or the Android System itself.In case of launcher activity its already true (incase if its false,then your app's activity won't launch)

Check app for static shortcuts and app-dynamic for dynamic shortcuts ⬆️

This guide can also be used for Kotlin based android apps.

If this helped you can rate me 🌟🌟
Regards.

android-shortcuts's People

Contributors

jayantur13 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.