Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.Activity;

import android.content.ContentResolver;

import android.database.Cursor;

import android.net.Uri;

public class Main {

    public static boolean isExistShortcut(Activity context, String authorities) {
        boolean isInstallShortcut = false;
        final ContentResolver cr = context.getContentResolver();

        final Uri CONTENT_URI = Uri.parse("content://" + authorities + "/favorites?notify=true");
        Cursor c = cr.query(CONTENT_URI, new String[] { "iconPackage" }, "iconPackage=?",
                new String[] { context.getApplication().getPackageName() }, null);
        if (c != null) {
            if (c.getCount() > 0) {
                isInstallShortcut = true;
            }
            c.close();
        }
        return isInstallShortcut;
    }
}