當前位置: 首頁>>代碼示例>>Java>>正文


Java PackageManager.queryBroadcastReceivers方法代碼示例

本文整理匯總了Java中android.content.pm.PackageManager.queryBroadcastReceivers方法的典型用法代碼示例。如果您正苦於以下問題:Java PackageManager.queryBroadcastReceivers方法的具體用法?Java PackageManager.queryBroadcastReceivers怎麽用?Java PackageManager.queryBroadcastReceivers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.pm.PackageManager的用法示例。


在下文中一共展示了PackageManager.queryBroadcastReceivers方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findSystemApk

import android.content.pm.PackageManager; //導入方法依賴的package包/類
static Pair<String, Resources> findSystemApk(String action, PackageManager pm) {
    final Intent intent = new Intent(action);
    for (ResolveInfo info : pm.queryBroadcastReceivers(intent, 0)) {
        if (info.activityInfo != null &&
                (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
            final String packageName = info.activityInfo.packageName;
            try {
                final Resources res = pm.getResourcesForApplication(packageName);
                return Pair.create(packageName, res);
            } catch (NameNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
    return null;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:17,代碼來源:Utilities.java

示例2: getAvailableRewriters

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * Retrieve rewriter available as plugin for csipsimple.
 * 
 * @param ctxt context of application
 * @return A map of package name => Fancy name of rewriter
 */
public static Map<String, String> getAvailableRewriters(Context ctxt) {

    if (AVAILABLE_REWRITERS == null) {
        AVAILABLE_REWRITERS = new HashMap<String, String>();

        PackageManager packageManager = ctxt.getPackageManager();
        Intent it = new Intent(SipManager.ACTION_REWRITE_NUMBER);

        List<ResolveInfo> availables = packageManager.queryBroadcastReceivers(it, 0);
        for (ResolveInfo resInfo : availables) {
            ActivityInfo actInfos = resInfo.activityInfo;
            Log.d(THIS_FILE, "Found rewriter " + actInfos.packageName + " " + actInfos.name);
            if (packageManager.checkPermission(permission.PROCESS_OUTGOING_CALLS,
                    actInfos.packageName) == PackageManager.PERMISSION_GRANTED) {
                String packagedActivityName = (new ComponentName(actInfos.packageName,
                        actInfos.name)).flattenToString();
                AVAILABLE_REWRITERS.put(packagedActivityName,
                        (String) resInfo.loadLabel(packageManager));
            }
        }
    }

    return AVAILABLE_REWRITERS;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:31,代碼來源:RewriterPlugin.java

示例3: getAvailableCallHandlers

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * Retrieve outgoing call handlers available as plugin for csipsimple Also
 * contains stock call handler if available
 * 
 * @param ctxt context of application
 * @return A map of package name => Fancy name of call handler
 */
public static Map<String, String> getAvailableCallHandlers(Context ctxt) {

    if (AVAILABLE_HANDLERS == null) {
        AVAILABLE_HANDLERS = new HashMap<String, String>();

        PackageManager packageManager = ctxt.getPackageManager();
        Intent it = new Intent(SipManager.ACTION_GET_PHONE_HANDLERS);

        List<ResolveInfo> availables = packageManager.queryBroadcastReceivers(it, 0);
        for (ResolveInfo resInfo : availables) {
            ActivityInfo actInfos = resInfo.activityInfo;
            Log.d(THIS_FILE, "Found call handler " + actInfos.packageName + " " + actInfos.name);
            if (packageManager.checkPermission(permission.PROCESS_OUTGOING_CALLS,
                    actInfos.packageName) == PackageManager.PERMISSION_GRANTED) {
                String packagedActivityName = (new ComponentName(actInfos.packageName,
                        actInfos.name)).flattenToString();
                AVAILABLE_HANDLERS.put(packagedActivityName,
                        (String) resInfo.loadLabel(packageManager));
            }
        }
    }

    return AVAILABLE_HANDLERS;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:32,代碼來源:CallHandlerPlugin.java

示例4: getAvailableThemes

import android.content.pm.PackageManager; //導入方法依賴的package包/類
public static HashMap<String, String> getAvailableThemes(Context ctxt){
	HashMap<String, String> result = new HashMap<String, String>();
	result.put("", ctxt.getResources().getString(R.string.app_name));
	
	PackageManager packageManager = ctxt.getPackageManager();
	Intent it = new Intent(SipManager.ACTION_GET_DRAWABLES);
	
	List<ResolveInfo> availables = packageManager.queryBroadcastReceivers(it, 0);
	Log.d(THIS_FILE, "We found " + availables.size() + "themes");
	for(ResolveInfo resInfo : availables) {
		Log.d(THIS_FILE, "We have -- "+resInfo);
		ActivityInfo actInfos = resInfo.activityInfo;
		ComponentName cmp = new ComponentName(actInfos.packageName, actInfos.name);
		String label = (String) actInfos.loadLabel(packageManager);
		if(TextUtils.isEmpty(label)) {
		    label = (String) resInfo.loadLabel(packageManager);
		}
		result.put(cmp.flattenToString(), label);
	}
	
	return result;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:23,代碼來源:Theme.java

示例5: getReceiverName

import android.content.pm.PackageManager; //導入方法依賴的package包/類
private ActivityInfo getReceiverName (String pkg,
                                       PackageManager packageManager) {
    Intent intent = new Intent();
    intent.setPackage(pkg);
    //intent.setAction(Constants.ACTION_RECEIVE_MESSAGE);
    for (ResolveInfo resolveInfo : packageManager.queryBroadcastReceivers(intent,
            PackageManager.GET_RESOLVED_FILTER |
                    PackageManager.GET_DISABLED_COMPONENTS)) {
        ActivityInfo activityInfo = resolveInfo.activityInfo;
        if (!activityInfo.packageName.equals(pkg))
            continue;
        IntentFilter filter = resolveInfo.filter;
        if (filter != null && filter.hasAction(Constants.ACTION_RECEIVE_MESSAGE)) {
            return activityInfo;
        }
    }
    // Not found
    return null;
}
 
開發者ID:Trumeet,項目名稱:MiPushFramework,代碼行數:20,代碼來源:CheckAppSupportActivity.java

示例6: d

import android.content.pm.PackageManager; //導入方法依賴的package包/類
private static boolean d(Context context, String str, String str2) {
    PackageManager packageManager = context.getPackageManager();
    Intent intent = new Intent(str2);
    intent.setPackage(context.getPackageName());
    for (ResolveInfo resolveInfo : packageManager.queryBroadcastReceivers(intent, 0)) {
        ActivityInfo activityInfo = resolveInfo.activityInfo;
        if (activityInfo != null && activityInfo.name.equals(str)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:13,代碼來源:a.java

示例7: getRespondersForDataType

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * Determines the set of providers who may be able to provide data of the specified type,
 * based on their declared broadcast query receivers.
 */
public static Set<String> getRespondersForDataType(@NonNull Context context,
                                                   @NonNull String dataType) {
    require(context, notNullValue());
    require(dataType, notNullValue());

    PackageManager packageManager = context.getPackageManager();

    Intent intent = new Intent(dataType);
    intent.addCategory(QueryUtil.BBQ_CATEGORY);
    List<ResolveInfo> responderInfos =
            packageManager.queryBroadcastReceivers(intent, PackageManager.GET_RESOLVED_FILTER);

    HashSet<String> responders = new HashSet<>();
    for (ResolveInfo info : responderInfos) {
        responders.add(info.activityInfo.packageName);
    }

    return responders;
}
 
開發者ID:openid,項目名稱:OpenYOLO-Android,代碼行數:24,代碼來源:QueryUtil.java

示例8: findSystemApk

import android.content.pm.PackageManager; //導入方法依賴的package包/類
static Pair<String, Resources> findSystemApk(String action, PackageManager pm) {
    final Intent intent = new Intent(action);
    for (ResolveInfo info : pm.queryBroadcastReceivers(intent, 0)) {
        if (info.activityInfo != null &&
                (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
            final String packageName = info.activityInfo.packageName;
            try {
                final Resources res = pm.getResourcesForApplication(packageName);
                return Pair.create(packageName, res);
            } catch (NameNotFoundException e) {
                Log.w(TAG, "Failed to find resources for " + packageName);
            }
        }
    }
    return null;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:17,代碼來源:Utilities.java

示例9: get

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * Find and return partner details, or {@code null} if none exists. A partner package is marked
 * by a broadcast receiver declared in the manifest that handles the
 * {@code com.android.setupwizard.action.PARTNER_CUSTOMIZATION} intent action. The overlay
 * package must also be a system package.
 */
public static synchronized Partner get(Context context) {
    if (!sSearched) {
        PackageManager pm = context.getPackageManager();
        final Intent intent = new Intent(ACTION_PARTNER_CUSTOMIZATION);
        for (ResolveInfo info : pm.queryBroadcastReceivers(intent, 0)) {
            if (info.activityInfo == null) {
                continue;
            }
            final ApplicationInfo appInfo = info.activityInfo.applicationInfo;
            if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                try {
                    final Resources res = pm.getResourcesForApplication(appInfo);
                    sPartner = new Partner(appInfo.packageName, res);
                    break;
                } catch (NameNotFoundException e) {
                    Log.w(TAG, "Failed to find resources for " + appInfo.packageName);
                }
            }
        }
        sSearched = true;
    }
    return sPartner;
}
 
開發者ID:Trumeet,項目名稱:SetupWizardLibCompat,代碼行數:30,代碼來源:Partner.java

示例10: getDynCodecPlugins

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * Retrieve all dynamic codec plugins available in the platform
 * It will resolve for a given action available sip plugins
 * @param ctxt Context of the application
 * @param action Action of the plugin to be resolved
 * For example {@link SipManager#ACTION_GET_EXTRA_CODECS}, {@link SipManager.ACTION_GET_VIDEO_PLUGIN}
 * @return a map containing plugins infos and registrered component name as key
 */
public static Map<String, DynCodecInfos> getDynCodecPlugins(Context ctxt, String action){
    if(!CACHED_RESOLUTION.containsKey(action)) {
        HashMap<String, DynCodecInfos> plugins = new HashMap<String, DynCodecInfos>();
        
        PackageManager packageManager = ctxt.getPackageManager();
        Intent it = new Intent(action);
        
        List<ResolveInfo> availables = packageManager.queryBroadcastReceivers(it, 0);
        for(ResolveInfo resInfo : availables) {
            ActivityInfo actInfos = resInfo.activityInfo;
            if( packageManager.checkPermission(SipManager.PERMISSION_CONFIGURE_SIP, actInfos.packageName) == PackageManager.PERMISSION_GRANTED) {
                ComponentName cmp = new ComponentName(actInfos.packageName, actInfos.name);
                DynCodecInfos dynInfos;
                try {
                    dynInfos = new DynCodecInfos(ctxt, cmp);
                    plugins.put(cmp.flattenToString(), dynInfos);
                } catch (NameNotFoundException e) {
                    Log.e(THIS_FILE, "Error while retrieving infos from dyn codec ", e);
                }
            }
        }
        CACHED_RESOLUTION.put(action, plugins);
    }
    
    return CACHED_RESOLUTION.get(action);
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:35,代碼來源:ExtraPlugins.java

示例11: customReceiverPass

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * Check package's MiPush custom receiver (handle com.xiaomi.mipush.RECEIVE_MESSAGE action)
 * is enabled.
 * @see PushMessageReceiver
 * @see Constants#ACTION_RECEIVE_MESSAGE
 * @param info Package info
 * @return enable status. If this package not have custom receiver, will
 * still returns true.
 */
private boolean customReceiverPass (PackageInfo info, PackageManager packageManager) {
    //if (info.receivers == null)
    //    return true;
    Intent intent = new Intent();
    intent.setPackage(info.packageName);
    //intent.setAction(Constants.ACTION_RECEIVE_MESSAGE);
    for (ResolveInfo resolveInfo : packageManager.queryBroadcastReceivers(intent,
            PackageManager.GET_RESOLVED_FILTER |
    PackageManager.GET_DISABLED_COMPONENTS)) {
        ActivityInfo activityInfo = resolveInfo.activityInfo;
        if (!activityInfo.packageName.equals(info.packageName))
            continue;
        IntentFilter filter = resolveInfo.filter;
        if (filter != null && filter.hasAction(Constants.ACTION_RECEIVE_MESSAGE)) {
            boolean enabled = packageManager.getComponentEnabledSetting(new ComponentName(
                    activityInfo.packageName, activityInfo.name
            )) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
            Log4a.i(TAG, "Handle receiver: " + activityInfo.name +
            "; enabled: " + enabled);
            return enabled;
        }
    }
    Log4a.d(TAG, "Not found custom message receiver in " + info.packageName);
    // Not found
    return true;
}
 
開發者ID:Trumeet,項目名稱:MiPushFramework,代碼行數:36,代碼來源:CheckSupportUtils.java

示例12: isAddToHomeIntentSupported

import android.content.pm.PackageManager; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:15,代碼來源:ShortcutHelper.java

示例13: findAndCheckReceiverInfo

import android.content.pm.PackageManager; //導入方法依賴的package包/類
private static void findAndCheckReceiverInfo(PackageManager packageManager, Intent intent,
                                             Class<?> cls, Boolean[] boolArr) {
    int i;
    for (ResolveInfo resolveInfo : packageManager.queryBroadcastReceivers(intent, 16384)) {
        PackageItemInfo packageItemInfo = resolveInfo.activityInfo;
        if (packageItemInfo != null && cls.getCanonicalName().equals(packageItemInfo.name)) {
            if (boolArr[0].booleanValue() != packageItemInfo.enabled) {
                throw new a(String.format("Wrong attribute: %n    <receiver " +
                        "android:name=\"%1$s\" .../> android:enabled should be %<b.", new
                        Object[]{packageItemInfo.name, boolArr[0]}), packageItemInfo);
            } else if (boolArr[1].booleanValue() != packageItemInfo.exported) {
                throw new a(String.format("Wrong attribute: %n    <receiver " +
                        "android:name=\"%1$s\" .../> android:exported should be %<b.", new
                        Object[]{packageItemInfo.name, boolArr[1]}), packageItemInfo);
            } else {
                i = 1;
                if (i == 0) {
                    throw new a(String.format("<receiver android:name=\"%1$s\" /> is missing " +
                            "or disabled.", new Object[]{cls.getCanonicalName()}), null);
                }
            }
        }
    }
    i = 0;
    if (i == 0) {
        throw new a(String.format("<receiver android:name=\"%1$s\" /> is missing or disabled" +
                ".", new Object[]{cls.getCanonicalName()}), null);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:30,代碼來源:MiPushClient.java


注:本文中的android.content.pm.PackageManager.queryBroadcastReceivers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。