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


Java SearchIntents類代碼示例

本文整理匯總了Java中com.google.android.gms.actions.SearchIntents的典型用法代碼示例。如果您正苦於以下問題:Java SearchIntents類的具體用法?Java SearchIntents怎麽用?Java SearchIntents使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SearchIntents類屬於com.google.android.gms.actions包,在下文中一共展示了SearchIntents類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onNewIntent

import com.google.android.gms.actions.SearchIntents; //導入依賴的package包/類
protected void onNewIntent(Intent intent) {
    String action = intent.getAction();
    if (action != null && (action.equals(Intent.ACTION_SEARCH) || action.equals(SearchIntents.ACTION_SEARCH))) {
        mQuery = intent.getStringExtra(SearchManager.QUERY);
        mQuery = mQuery.replace(getString(R.string.product_voice_search)+" ","");
    }
}
 
開發者ID:BennSandoval,項目名稱:Woodmin,代碼行數:8,代碼來源:ProductsFragment.java

示例2: processIntent

import com.google.android.gms.actions.SearchIntents; //導入依賴的package包/類
private void processIntent(Intent intent) {
    super.onNewIntent(intent);
    String action = intent.getAction();
    if (action != null && (action.equals(Intent.ACTION_SEARCH) || action.equals(SearchIntents.ACTION_SEARCH))) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        if(query != null && query.length()>0){
            FragmentManager fragmentManager = getSupportFragmentManager();
            if(query.toLowerCase().contains(getString(R.string.product_voice_search).toLowerCase())){
                fragmentManager.beginTransaction()
                        .replace(R.id.container, ProductsFragment.newInstance(2))
                        .commit();
            } else if(query.toLowerCase().contains(getString(R.string.customer_voice_search).toLowerCase())){
                fragmentManager.beginTransaction()
                        .replace(R.id.container, CustomersFragment.newInstance(1))
                        .commit();
            } else {
                fragmentManager.beginTransaction()
                        .replace(R.id.container, OrdersFragment.newInstance(1))
                        .commit();
            }
        }
    }
}
 
開發者ID:BennSandoval,項目名稱:Woodmin,代碼行數:24,代碼來源:MainActivity.java

示例3: onNewIntent

import com.google.android.gms.actions.SearchIntents; //導入依賴的package包/類
protected void onNewIntent(Intent intent) {
    String action = intent.getAction();
    if (action != null && (action.equals(Intent.ACTION_SEARCH) || action.equals(SearchIntents.ACTION_SEARCH))) {
        mQuery = intent.getStringExtra(SearchManager.QUERY);
        mQuery = mQuery.replace(getString(R.string.customer_voice_search)+" ","");
    }
}
 
開發者ID:BennSandoval,項目名稱:Woodmin,代碼行數:8,代碼來源:CustomersFragment.java

示例4: onNewIntent

import com.google.android.gms.actions.SearchIntents; //導入依賴的package包/類
protected void onNewIntent(Intent intent) {
    String action = intent.getAction();
    if (action != null && (action.equals(Intent.ACTION_SEARCH) || action.equals(SearchIntents.ACTION_SEARCH))) {
        mQuery = intent.getStringExtra(SearchManager.QUERY);
        mQuery = mQuery.replace(getString(R.string.order_voice_search) + " ","");
    }
}
 
開發者ID:BennSandoval,項目名稱:Woodmin,代碼行數:8,代碼來源:OrdersFragment.java

示例5: onCreate

import com.google.android.gms.actions.SearchIntents; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_searchable);
    ButterKnife.bind(this);

    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())
            ||  SearchIntents.ACTION_SEARCH.equals(getIntent().getAction())) {
        Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.content_fl);
        if(fragment == null){
            fragment = SearchableFragment.newInstance(getIntent().getExtras());
            getSupportFragmentManager()
                    .beginTransaction()
                    .replace(R.id.content_fl, fragment, "")
                    .commit();
        } else {
            getSupportFragmentManager()
                    .beginTransaction()
                    .attach(fragment)
                    .commit();
        }
    }

    compositeSubscription = new CompositeSubscription();

    setUpRxBusSubscription();
}
 
開發者ID:lawloretienne,項目名稱:Loop,代碼行數:28,代碼來源:SearchableActivity.java

示例6: handleSearchIntent

import com.google.android.gms.actions.SearchIntents; //導入依賴的package包/類
/**
 * If the provided intent is a search intent, the query operation it contains will be performed.
 * Currently only the {@link Intent#ACTION_SEARCH} and {@link SearchIntents#ACTION_SEARCH}
 * intents are supported to filter food trucks by the given search query.
 * <p/>
 * If the provided intent is not a search intent, no action will be taken.
 *
 * @param intent that was passed to this activity. This does not have to be a search intent.
 */
private void handleSearchIntent(@NonNull Intent intent) {
    String query = intent.getStringExtra(SearchManager.QUERY);
    String action = intent.getAction();

    if (action == null) {
        return;
    }

    switch (action) {
        case SearchIntents.ACTION_SEARCH:
            Timber.i("Google Now search");
            searchView.setIconified(false);
            searchView.setQuery(query, true);
            break;
        case Intent.ACTION_SEARCH:
            Timber.i("Action Bar search");
            boolean repeatQuery = query == null ? lastQuery == null : query.equals(lastQuery);

            // Don't need to redo the search if it's the same as last time
            if (!repeatQuery) {
                if (currentFragment instanceof Searchable) {
                    ((Searchable) currentFragment).doSearch(query);
                }

                lastQuery = query;
            }
    }
}
 
開發者ID:TruckMuncher,項目名稱:TruckMuncher-Android,代碼行數:38,代碼來源:MainActivity.java


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