Example usage for android.content.pm ShortcutManager reportShortcutUsed

List of usage examples for android.content.pm ShortcutManager reportShortcutUsed

Introduction

In this page you can find the example usage for android.content.pm ShortcutManager reportShortcutUsed.

Prototype

public void reportShortcutUsed(String shortcutId) 

Source Link

Document

Apps that publish shortcuts should call this method whenever the user selects the shortcut containing the given ID or when the user completes an action in the app that is equivalent to selecting the shortcut.

Usage

From source file:com.android.contacts.DynamicShortcuts.java

public static void reportShortcutUsed(Context context, String lookupKey) {
    if (!CompatUtils.isLauncherShortcutCompatible() || lookupKey == null)
        return;//from www  . j ava  2 s .  c o  m
    final ShortcutManager shortcutManager = (ShortcutManager) context
            .getSystemService(Context.SHORTCUT_SERVICE);
    shortcutManager.reportShortcutUsed(lookupKey);
}

From source file:com.hacktx.android.activities.CheckInActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_check_in);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);//w  ww  . j a  v a  2  s  .c  o m

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle(R.string.activity_check_in_title);
    }

    if (getIntent().getBooleanExtra("fromShortcut", false)
            && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
        shortcutManager.reportShortcutUsed("check-in");
    }

    setupStatusBar();
    setupCards();
}