private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
//set the text on the search view without submission
searchView.setQuery(query, false);
searchView.clearFocus();
//save search result
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
ArtistsSearchRecentSuggestionsProvider.AUTHORITY,
ArtistsSearchRecentSuggestionsProvider.MODE);
suggestions.saveRecentQuery(query, null);
viewModel.query(query);
//use the query to search your data somehow
Toast.makeText(this, query, Toast.LENGTH_SHORT).show();
}
}
java类android.provider.SearchRecentSuggestions的实例源码
ShoppingActivity.java 文件源码
项目:SampleAppArch
阅读 25
收藏 0
点赞 0
评论 0
SettingsFragment.java 文件源码
项目:ultrasonic
阅读 32
收藏 0
点赞 0
评论 0
private void setupClearSearchPreference() {
Preference clearSearchPreference = findPreference(Constants.PREFERENCES_KEY_CLEAR_SEARCH_HISTORY);
if (clearSearchPreference != null) {
clearSearchPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
SearchRecentSuggestions suggestions =
new SearchRecentSuggestions(getActivity(),
SearchSuggestionProvider.AUTHORITY,
SearchSuggestionProvider.MODE);
suggestions.clearHistory();
Util.toast(getActivity(), R.string.settings_search_history_cleared);
return false;
}
});
}
}
QueryReceiverActivity.java 文件源码
项目:ultrasonic
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
String query = getIntent().getStringExtra(SearchManager.QUERY);
if (query != null)
{
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(query, null);
Intent intent = new Intent(QueryReceiverActivity.this, SearchActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_QUERY, query);
startActivityForResultWithoutTransition(QueryReceiverActivity.this, intent);
}
finish();
Util.disablePendingTransition(this);
}
VoiceQueryReceiverActivity.java 文件源码
项目:ultrasonic
阅读 27
收藏 0
点赞 0
评论 0
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
String query = getIntent().getStringExtra(SearchManager.QUERY);
if (query != null)
{
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(query, null);
Intent intent = new Intent(VoiceQueryReceiverActivity.this, SearchActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_QUERY, query);
intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
startActivityForResultWithoutTransition(VoiceQueryReceiverActivity.this, intent);
}
finish();
Util.disablePendingTransition(this);
}
FindFragment.java 文件源码
项目:Farmacias
阅读 31
收藏 0
点赞 0
评论 0
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utils.logD(LOG_TAG, "onCreate");
mSharedPreferences = new PreferencesManagerImp(getActivity().getApplicationContext());
mLocation = mSharedPreferences.getLocation();
if (savedInstanceState != null) {
mRotation = true;
}
LoaderProvider loaderProvider = new LoaderProvider(getContext());
LoaderManager loaderManager = getLoaderManager();
Geocoder geocoder = new Geocoder(getActivity());
// loaderManager.enableDebugLogging(true);
mPresenter = new FindPresenter(mLocation, loaderManager, loaderProvider, geocoder);
setHasOptionsMenu(true);
mRecentSearchSuggestions = new SearchRecentSuggestions(getContext(),
RecentSuggestionsProvider.AUTHORITY, RecentSuggestionsProvider.MODE);
mCompositeSubscription = new CompositeSubscription();
mActivityCoordinator = (CoordinatorLayout) getActivity().findViewById(R.id.coordinator);
mSnackCoordinator = (CoordinatorLayout) getActivity().findViewById(R.id.coordinatorSnackContainer);
}
SearchActivity.java 文件源码
项目:materialistic
阅读 44
收藏 0
点赞 0
评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
if (getIntent().hasExtra(SearchManager.QUERY)) {
mQuery = getIntent().getStringExtra(SearchManager.QUERY);
}
super.onCreate(savedInstanceState);
if (!TextUtils.isEmpty(mQuery)) {
getSupportActionBar().setSubtitle(mQuery);
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
SearchRecentSuggestionsProvider.PROVIDER_AUTHORITY,
SearchRecentSuggestionsProvider.MODE) {
@Override
public void saveRecentQuery(String queryString, String line2) {
truncateHistory(getContentResolver(), MAX_RECENT_SUGGESTIONS - 1);
super.saveRecentQuery(queryString, line2);
}
};
suggestions.saveRecentQuery(mQuery, null);
}
}
SearchVenuesActivity.java 文件源码
项目:foursquared.eclair
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void onNewIntent(Intent intent) {
if (DEBUG) Log.d(TAG, "New Intent: " + intent);
String action = intent.getAction();
String query = intent.getStringExtra(SearchManager.QUERY);
if (intent == null) {
if (DEBUG) Log.d(TAG, "No intent to search, querying default.");
executeSearchTask(query);
} else if (Intent.ACTION_SEARCH.equals(action) && query != null) {
if (DEBUG) Log.d(TAG, "onNewIntent received search intent and saving.");
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
VenueQuerySuggestionsProvider.AUTHORITY, VenueQuerySuggestionsProvider.MODE);
suggestions.saveRecentQuery(query, null);
executeSearchTask(query);
} else {
onSearchRequested();
}
}
SearchMainParentFragment.java 文件源码
项目:WeiboWeiBaTong
阅读 20
收藏 0
点赞 0
评论 0
private void search(final String q) {
if (!TextUtils.isEmpty(q)) {
this.q = q;
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(this.q, null);
switch (viewPager.getCurrentItem()) {
case 0:
((SearchStatusFragment) getSearchWeiboFragment()).search();
break;
case 1:
((SearchUserFragment) getSearchUserFragment()).search();
break;
}
}
}
MainActivity.java 文件源码
项目:Leaderboards
阅读 26
收藏 0
点赞 0
评论 0
@Override
public boolean onQueryTextSubmit(String query) {
//Avoid bug: this is called twice in some devices (ACTION_UP and ACTION_DOWN)
long actualSearchTime = Calendar.getInstance().getTimeInMillis();
if (actualSearchTime < lastSearchTime + 1000)
return true;
lastSearchTime = actualSearchTime;
if (TextUtils.isEmpty(query)) {
mAdapter.clearAll();
} else {
lastQuery = query;
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
RecentSearchProvider.AUTHORITY, RecentSearchProvider.MODE);
suggestions.saveRecentQuery(query, null);
mAdapter.getFilter().filter(query);
}
return true;
}
SearchActivity.java 文件源码
项目:custom-searchable
阅读 28
收藏 0
点赞 0
评论 0
private void sendSearchIntent () {
try {
Intent sendIntent = new Intent(this, Class.forName(searchableActivity));
sendIntent.setAction(Intent.ACTION_SEARCH);
sendIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
sendIntent.putExtra(SearchManager.QUERY, query);
// If it is set one-line mode, directly saves the suggestion in the provider
if (!CustomSearchableInfo.getIsTwoLineExhibition()) {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, providerAuthority, SearchRecentSuggestionsProvider.DATABASE_MODE_QUERIES);
suggestions.saveRecentQuery(query, null);
}
startActivity(sendIntent);
finish();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
SearchActivity.java 文件源码
项目:custom-searchable
阅读 38
收藏 0
点赞 0
评论 0
private Cursor queryRecentSuggestionsProvider () {
Uri uri = Uri.parse("content://".concat(providerAuthority.concat("/suggestions")));
String[] selection;
if (CustomSearchableInfo.getIsTwoLineExhibition()) {
selection = SearchRecentSuggestions.QUERIES_PROJECTION_2LINE;
} else {
selection = SearchRecentSuggestions.QUERIES_PROJECTION_1LINE;
}
String[] selectionArgs = new String[] {"%" + query + "%"};
return SearchActivity.this.getContentResolver().query(
uri,
selection,
"display1 LIKE ?",
selectionArgs,
"date DESC"
);
}
SearchMainParentFragment.java 文件源码
项目:Dingyu
阅读 22
收藏 0
点赞 0
评论 0
private void search(final String q) {
if (!TextUtils.isEmpty(q)) {
this.q = q;
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(this.q, null);
switch (viewPager.getCurrentItem()) {
case 0:
((SearchStatusFragment) getSearchWeiboFragment()).search();
break;
case 1:
((SearchUserFragment) getSearchUserFragment()).search();
break;
}
}
}
SearchMainParentFragment.java 文件源码
项目:WeiboWeiBaTong
阅读 23
收藏 0
点赞 0
评论 0
private void search(final String q) {
if (!TextUtils.isEmpty(q)) {
this.q = q;
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(this.q, null);
switch (viewPager.getCurrentItem()) {
case 0:
((SearchStatusFragment) getSearchWeiboFragment()).search();
break;
case 1:
((SearchUserFragment) getSearchUserFragment()).search();
break;
}
}
}
SearchMainParentFragment.java 文件源码
项目:siciyuan
阅读 20
收藏 0
点赞 0
评论 0
private void search(final String q) {
if (!TextUtils.isEmpty(q)) {
this.q = q;
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(this.q, null);
switch (viewPager.getCurrentItem()) {
case 0:
((SearchStatusFragment) getSearchWeiboFragment()).search();
break;
case 1:
((SearchUserFragment) getSearchUserFragment()).search();
break;
}
}
}
MainActivity.java 文件源码
项目:AndroidMobileWorkplace
阅读 26
收藏 0
点赞 0
评论 0
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.action_clear_history:
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
MySuggestionProvider.AUTHORITY, MySuggestionProvider.MODE);
suggestions.clearHistory();
return true;
case R.id.action_search:
onSearchRequested();
return true;
case R.id.action_about:
startActivity(new Intent(this, About.class));
return true;
case R.id.action_update_yp:
YellowPagesLoader.getInstance(this).fetchDataAsync();
return true;
}
return (super.onOptionsItemSelected(menuItem));
}
SearchQueryResults.java 文件源码
项目:Flight-Computer-Android-Flightradar24
阅读 18
收藏 0
点赞 0
评论 0
private void doSearchQuery(final Intent queryIntent, final String entryPoint) {
// The search query is provided as an "extra" string in the query intent
final String queryString = queryIntent.getStringExtra(SearchManager.QUERY);
// Record the query string in the recent queries suggestions provider.
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(queryString, null);
// Do the actual search, write to searchResults field
showDialog(SEARCH_DIALOG);
MapQuestGeocoder geocoder = new MapQuestGeocoder();
geocoder.geocode(queryString, null, this, MAPQUEST_KEY);
}
RecipeItemListActivity.java 文件源码
项目:android-recipes-app
阅读 24
收藏 0
点赞 0
评论 0
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
if (!TextUtils.isEmpty(query)) {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
SearchRecipeSuggestionsProvider.AUTHORITY,
SearchRecipeSuggestionsProvider.MODE);
suggestions.saveRecentQuery(query, null);
}
recipeListFragment.setQuery(query);
}
}
PreferenceSim2Activity.java 文件源码
项目:sms_DualCard
阅读 22
收藏 0
点赞 0
评论 0
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case CONFIRM_CLEAR_SEARCH_HISTORY_DIALOG:
return new AlertDialog.Builder(PreferenceSim2Activity.this)
.setTitle(R.string.confirm_clear_search_title)
.setMessage(R.string.confirm_clear_search_text)
.setPositiveButton(android.R.string.ok,
new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
SearchRecentSuggestions recent = ((MmsApp) getApplication())
.getRecentSuggestions();
if (recent != null) {
recent.clearHistory();
}
dialog.dismiss();
}
}).setNegativeButton(android.R.string.cancel, null)
.setIcon(android.R.drawable.ic_dialog_alert).create();
}
return super.onCreateDialog(id);
}
MessagingPreferenceActivity.java 文件源码
项目:sms_DualCard
阅读 21
收藏 0
点赞 0
评论 0
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case CONFIRM_CLEAR_SEARCH_HISTORY_DIALOG:
return new AlertDialog.Builder(MessagingPreferenceActivity.this)
.setTitle(R.string.confirm_clear_search_title)
.setMessage(R.string.confirm_clear_search_text)
.setPositiveButton(android.R.string.ok,
new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
SearchRecentSuggestions recent = ((MmsApp) getApplication())
.getRecentSuggestions();
if (recent != null) {
recent.clearHistory();
}
dialog.dismiss();
}
}).setNegativeButton(android.R.string.cancel, null)
.setIcon(android.R.drawable.ic_dialog_alert).create();
}
return super.onCreateDialog(id);
}
PreferenceSim1Activity.java 文件源码
项目:sms_DualCard
阅读 19
收藏 0
点赞 0
评论 0
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case CONFIRM_CLEAR_SEARCH_HISTORY_DIALOG:
return new AlertDialog.Builder(PreferenceSim1Activity.this)
.setTitle(R.string.confirm_clear_search_title)
.setMessage(R.string.confirm_clear_search_text)
.setPositiveButton(android.R.string.ok,
new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
SearchRecentSuggestions recent = ((MmsApp) getApplication())
.getRecentSuggestions();
if (recent != null) {
recent.clearHistory();
}
dialog.dismiss();
}
}).setNegativeButton(android.R.string.cancel, null)
.setIcon(android.R.drawable.ic_dialog_alert).create();
}
return super.onCreateDialog(id);
}
FeedTabActivity.java 文件源码
项目:MALFriends
阅读 23
收藏 0
点赞 0
评论 0
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
viewPager.setCurrentItem(TabPagerAdapter.ANIME_TAB, true);
String query = intent.getStringExtra(SearchManager.QUERY);
if (menuItemSearchView != null) {
MenuItemCompat.collapseActionView(menuItemSearchView);
}
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(
this, SearchFriendsProvider.AUTHORITY,
SearchFriendsProvider.MODE);
suggestions.saveRecentQuery(query, null);
// call method that handles the search request
if (RequestHelper.isNetworkAvailable(FeedTabActivity.this)) {
//startFeedRequests(query);
notifyFragments(query);
} else {
Toast.makeText(this, R.string.no_network_connection_available,
Toast.LENGTH_LONG).show();
}
}
}
GeneralPreferences.java 文件源码
项目:Calendar_lunar
阅读 23
收藏 0
点赞 0
评论 0
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference) {
final String key = preference.getKey();
if (KEY_CLEAR_SEARCH_HISTORY.equals(key)) {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(
getActivity(), Utils.getSearchAuthority(getActivity()),
CalendarRecentSuggestionsProvider.MODE);
suggestions.clearHistory();
Toast.makeText(getActivity(), R.string.search_history_cleared,
Toast.LENGTH_SHORT).show();
return true;
} else {
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
}
SearchActivity.java 文件源码
项目:Calendar_lunar
阅读 38
收藏 0
点赞 0
评论 0
private void search(String searchQuery, Time goToTime) {
// save query in recent queries
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
Utils.getSearchAuthority(this),
CalendarRecentSuggestionsProvider.MODE);
suggestions.saveRecentQuery(searchQuery, null);
EventInfo searchEventInfo = new EventInfo();
searchEventInfo.eventType = EventType.SEARCH;
searchEventInfo.query = searchQuery;
searchEventInfo.viewType = ViewType.AGENDA;
if (goToTime != null) {
searchEventInfo.startTime = goToTime;
}
mController.sendEvent(this, searchEventInfo);
mQuery = searchQuery;
if (mSearchView != null) {
mSearchView.setQuery(mQuery, false);
mSearchView.clearFocus();
}
}
SearchableActivity.java 文件源码
项目:Androzic
阅读 29
收藏 0
点赞 0
评论 0
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case android.R.id.home:
thread = null;
finish();
return true;
case R.id.action_clear:
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SuggestionProvider.AUTHORITY, SuggestionProvider.MODE);
suggestions.clearHistory();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
MessagingPreferenceActivity.java 文件源码
项目:android-aosp-mms
阅读 19
收藏 0
点赞 0
评论 0
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case CONFIRM_CLEAR_SEARCH_HISTORY_DIALOG:
return new AlertDialog.Builder(MessagingPreferenceActivity.this)
.setTitle(R.string.confirm_clear_search_title)
.setMessage(R.string.confirm_clear_search_text)
.setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
SearchRecentSuggestions recent =
((MmsApp)getApplication()).getRecentSuggestions();
if (recent != null) {
recent.clearHistory();
}
dialog.dismiss();
}
})
.setNegativeButton(android.R.string.cancel, null)
.setIconAttribute(android.R.attr.alertDialogIcon)
.create();
}
return super.onCreateDialog(id);
}
ActivityForSearching.java 文件源码
项目:TumCampusApp
阅读 35
收藏 0
点赞 0
评论 0
/**
* Tests if search query is valid and internet connection is available.
* Then starts a new search.
*
* @param query Query to search for
*/
protected void requestSearch(String query) {
mQuery = query;
if (query.length() < mMinLength) {
final String text = String.format(getString(R.string.min_search_len), mMinLength);
Utils.showToast(this, text);
return;
}
/*if (!Utils.isConnected(this)) {
showNoInternetLayout();
return;
}*/
// Add query to recents
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, mAuthority, SearchRecentSuggestionsProvider.DATABASE_MODE_QUERIES);
suggestions.saveRecentQuery(query, null);
// Tell activity to start searching
onStartSearch(query);
}
ClearSearchSuggestions.java 文件源码
项目:buildAPKsApps
阅读 21
收藏 0
点赞 0
评论 0
@Override
protected void onClick() {
// Data has changed, notify so UI can be refreshed!
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getContext(),
SearchSuggestions.AUTHORITY, SearchSuggestions.MODE);
suggestions.clearHistory();
Toast.makeText(getContext(), R.string.onSuggestionsCleared, Toast.LENGTH_SHORT).show();
notifyChanged();
}
ClearSearchSuggestions.java 文件源码
项目:encdroidMC
阅读 20
收藏 0
点赞 0
评论 0
@Override
protected void onClick() {
// Data has changed, notify so UI can be refreshed!
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getContext(),
SearchSuggestions.AUTHORITY, SearchSuggestions.MODE);
suggestions.clearHistory();
Toast.makeText(getContext(), R.string.onSuggestionsCleared, Toast.LENGTH_SHORT).show();
notifyChanged();
}
Presenter.java 文件源码
项目:Programmers
阅读 39
收藏 0
点赞 0
评论 0
@Override
public void onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_delete) {
SearchRecentSuggestions recentSuggestions = new SearchRecentSuggestions(getContext(),
SearchableProvider.AUTHORITY,
SearchableProvider.MODE);
recentSuggestions.clearHistory();
view.showToast(getContext().getString(R.string.search_history_deleted));
}
}
EntityListFragment.java 文件源码
项目:Ymir
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void run() {
//Se a pesquisa não retornou nada, não salva a sugestão.
//Esta verificação não conflitará com outras pesquisas pois está sendo executado na Thread de UI.
if (entityListAdapter.getItemCount() == 0) {
return;
}
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
EntitySearchSuggestionsProvider.AUTHORITY,
EntitySearchSuggestionsProvider.MODE);
suggestions.saveRecentQuery(query, searchEntity);
}