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


Java SearchManager.getGlobalSearchActivity方法代碼示例

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


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

示例1: get

import android.app.SearchManager; //導入方法依賴的package包/類
/**
 * -     * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}
 * -     * provided by the same package which is set to be global search activity.
 * -     * If widgetCategory is not supported, or no such widget is found, returns the first widget
 * -     * provided by the package.
 * -
 */
public static AppWidgetProviderInfo get(Context context) {
    SearchManager searchManager =
            (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
    ComponentName searchComponent = searchManager.getGlobalSearchActivity();
    if (searchComponent == null) return null;
    String providerPkg = searchComponent.getPackageName();

    AppWidgetProviderInfo defaultWidgetForSearchPackage = null;

    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) {
        if (info.provider.getPackageName().equals(providerPkg) && info.configure == null) {
            if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) {
                return info;
            } else if (defaultWidgetForSearchPackage == null) {
                defaultWidgetForSearchPackage = info;
            }
        }
    }
    return defaultWidgetForSearchPackage;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:29,代碼來源:SearchWidgetProvider.java

示例2: startGoogleSearchActivity

import android.app.SearchManager; //導入方法依賴的package包/類
public static void startGoogleSearchActivity(View view) {
    final Context context = view.getContext();

    final SearchManager searchManager =
            (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
    if (searchManager == null) {
        return;
    }

    ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
    if (globalSearchActivity == null) {
        return;
    }

    Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setComponent(globalSearchActivity);

    Bundle appSearchData = new Bundle();
    appSearchData.putString("source", context.getPackageName());

    intent.putExtra(SearchManager.APP_DATA, appSearchData);
    intent.setSourceBounds(getViewBounds(view));
    try {
        context.startActivity(intent);
    } catch (ActivityNotFoundException ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:OhMyLob,項目名稱:Paper-Launcher,代碼行數:30,代碼來源:IntentUtil.java

示例3: getSearchWidgetProvider

import android.app.SearchManager; //導入方法依賴的package包/類
/**
 * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX}
 * provided by the same package which is set to be global search activity.
 * If widgetCategory is not supported, or no such widget is found, returns the first widget
 * provided by the package.
 */
public static AppWidgetProviderInfo getSearchWidgetProvider(Context context) {
    SearchManager searchManager =
            (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
    ComponentName searchComponent = searchManager.getGlobalSearchActivity();
    if (searchComponent == null) return null;
    String providerPkg = searchComponent.getPackageName();

    AppWidgetProviderInfo defaultWidgetForSearchPackage = null;

    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) {
        if (info.provider.getPackageName().equals(providerPkg) && info.configure == null) {
            if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) {
                return info;
            } else if (defaultWidgetForSearchPackage == null) {
                defaultWidgetForSearchPackage = info;
            }
        }
    }
    return defaultWidgetForSearchPackage;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:28,代碼來源:QsbContainerView.java


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