本文整理匯總了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)+" ","");
}
}
示例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();
}
}
}
}
示例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)+" ","");
}
}
示例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) + " ","");
}
}
示例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();
}
示例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;
}
}
}