Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.ComponentName;

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

import android.content.pm.ApplicationInfo;

import android.content.pm.PackageManager;

public class Main {
    public static void delShortcutFromDesktop(Context paramContext, String packageName, String cls,
            String appName) {
        Intent localIntent1 = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");
        String str = appName;
        PackageManager localPackageManager = paramContext.getPackageManager();
        int i = 8320;
        try {
            ApplicationInfo localApplicationInfo = localPackageManager.getApplicationInfo(packageName, i);
            if (str == null)
                str = localPackageManager.getApplicationLabel(localApplicationInfo).toString();
            localIntent1.putExtra("android.intent.extra.shortcut.NAME", str);
            ComponentName localComponentName = new ComponentName(packageName, cls);
            Intent localIntent2 = new Intent(Intent.ACTION_MAIN).setComponent(localComponentName);
            localIntent2.addCategory(Intent.CATEGORY_LAUNCHER);
            localIntent1.putExtra("android.intent.extra.shortcut.INTENT", localIntent2);
            paramContext.sendBroadcast(localIntent1);
            return;
        } catch (PackageManager.NameNotFoundException localNameNotFoundException) {
            while (true)
                localNameNotFoundException.printStackTrace();
        }
    }
}