delete Shortcut via Intent - Android Intent

Android examples for Intent:Short cut

Description

delete Shortcut via Intent

Demo Code


//package com.java2s;

import android.content.Context;
import android.content.Intent;

import android.content.pm.PackageManager;

public class Main {

    public static void delShortcut(Context cx) {
        Intent shortcut = new Intent(
                "com.android.launcher.action.UNINSTALL_SHORTCUT");

        String title = null;/*from   w  ww .  j a  v a  2  s.  c om*/
        try {
            final PackageManager pm = cx.getPackageManager();
            title = pm.getApplicationLabel(
                    pm.getApplicationInfo(cx.getPackageName(),
                            PackageManager.GET_META_DATA)).toString();
        } catch (Exception e) {
        }
        shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
        Intent shortcutIntent = cx.getPackageManager()
                .getLaunchIntentForPackage(cx.getPackageName());
        shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
        cx.sendBroadcast(shortcut);
    }
}

Related Tutorials