use of android.app.SearchManager in project Fairphone by Kwamecorp.
the class LauncherTransitionable method startGlobalSearch.
/**
* Starts the global search activity. This code is a copied from
* SearchManager
*/
public void startGlobalSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds) {
final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity();
if (globalSearchActivity == null) {
Log.w(TAG, "No global search activity found.");
return;
}
Intent intent = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(globalSearchActivity);
// Make sure that we have a Bundle to put source in
if (appSearchData == null) {
appSearchData = new Bundle();
} else {
appSearchData = new Bundle(appSearchData);
}
// set already.
if (!appSearchData.containsKey("source")) {
appSearchData.putString("source", getPackageName());
}
intent.putExtra(SearchManager.APP_DATA, appSearchData);
if (!TextUtils.isEmpty(initialQuery)) {
intent.putExtra(SearchManager.QUERY, initialQuery);
}
if (selectInitialQuery) {
intent.putExtra(SearchManager.EXTRA_SELECT_QUERY, selectInitialQuery);
}
intent.setSourceBounds(sourceBounds);
try {
startActivity(intent);
} catch (ActivityNotFoundException ex) {
Log.e(TAG, "Global search activity not found: " + globalSearchActivity);
}
}
use of android.app.SearchManager in project materialistic by hidroh.
the class BaseListActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (mIsMultiPane) {
getMenuInflater().inflate(R.menu.menu_item_compact, menu);
}
if (isSearchable()) {
getMenuInflater().inflate(R.menu.menu_search, menu);
MenuItem menuSearch = menu.findItem(R.id.menu_search);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch);
searchView.setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(this, SearchActivity.class)));
searchView.setIconified(true);
searchView.setQuery("", false);
}
return super.onCreateOptionsMenu(menu);
}
use of android.app.SearchManager in project Android-Developers-Samples by johnjohndoe.
the class MainActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
// Associate searchable configuration with the SearchView
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
return true;
}
use of android.app.SearchManager in project Talon-for-Twitter by klinker24.
the class SearchPager method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.search_activity, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(true);
int searchImgId = getResources().getIdentifier("android:id/search_button", null, null);
ImageView view = (ImageView) searchView.findViewById(searchImgId);
view.setImageResource(settings.theme == AppSettings.THEME_LIGHT ? R.drawable.ic_action_search_light : R.drawable.ic_action_search_dark);
return true;
}
use of android.app.SearchManager in project android by owncloud.
the class SearchShareesFragment method onCreateView.
/**
* {@inheritDoc}
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.search_users_groups_layout, container, false);
// Get the SearchView and set the searchable configuration
SearchView searchView = (SearchView) view.findViewById(R.id.searchView);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager.getSearchableInfo(// assumes parent activity is the searchable activity
getActivity().getComponentName()));
// do not iconify the widget; expand it by default
searchView.setIconifiedByDefault(false);
// avoid fullscreen with softkeyboard
searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Log_OC.v(TAG, "onQueryTextSubmit intercepted, query: " + query);
// return true to prevent the query is processed to be queried;
return true;
// a user / group will be picked only if selected in the list of suggestions
}
@Override
public boolean onQueryTextChange(String newText) {
// let it for the parent listener in the hierarchy / default behaviour
return false;
}
});
return view;
}
Aggregations