Java tutorial
//package com.java2s; // Use of this source code is governed by a BSD-style license that can be import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import java.util.List; public class Main { private static final String INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT"; /** * Utility method to check if a shortcut can be added to the home screen. * @param context Context used to get the package manager. * @return if a shortcut can be added to the home screen under the current profile. */ // TODO(crbug.com/635567): Fix this properly. @SuppressLint("WrongConstant") public static boolean isAddToHomeIntentSupported(Context context) { PackageManager pm = context.getPackageManager(); Intent i = new Intent(INSTALL_SHORTCUT); List<ResolveInfo> receivers = pm.queryBroadcastReceivers(i, PackageManager.GET_INTENT_FILTERS); return !receivers.isEmpty(); } }