Java Code Examples for android.app.SearchManager

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Airports, under directory /src/com/nadmm/airports/.

Source file: ActivityBase.java

  22 
vote

@TargetApi(11) @Override public boolean onCreateOptionsMenu(Menu menu){
  MenuInflater inflater=getSupportMenuInflater();
  inflater.inflate(R.menu.mainmenu,menu);
  mRefreshItem=menu.findItem(R.id.menu_refresh);
  mRefreshDrawable=mRefreshItem.getIcon();
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    SearchManager searchManager=(SearchManager)getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView=new SearchView(getSupportActionBar().getThemedContext());
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    menu.findItem(R.id.menu_search).setActionView(searchView);
  }
  return super.onCreateOptionsMenu(menu);
}
 

Example 2

From project Hax-Launcher, under directory /src/com/t3hh4xx0r/haxlauncher/.

Source file: Launcher.java

  22 
vote

/** 
 * Indicates that we want global search for this activity by setting the globalSearch argument for  {@link #startSearch} to true.
 */
@Override public void startSearch(String initialQuery,boolean selectInitialQuery,Bundle appSearchData,boolean globalSearch){
  showWorkspace(true);
  if (initialQuery == null) {
    initialQuery=getTypedText();
  }
  if (appSearchData == null) {
    appSearchData=new Bundle();
    appSearchData.putString("source","launcher-search");
  }
  Rect sourceBounds=mSearchDropTargetBar.getSearchBarBounds();
  final SearchManager searchManager=(SearchManager)getSystemService(Context.SEARCH_SERVICE);
  searchManager.startSearch(initialQuery,selectInitialQuery,getComponentName(),appSearchData,globalSearch);
}
 

Example 3

From project HeLauncher, under directory /src/com/handlerexploit/launcher_reloaded/.

Source file: Launcher.java

  22 
vote

/** 
 * Cancel search dialog if it is open.
 */
void stopSearch(){
  SearchManager searchManager=(SearchManager)getSystemService(Context.SEARCH_SERVICE);
  searchManager.stopSearch();
  Search searchWidget=mWorkspace.findSearchWidgetOnCurrentScreen();
  if (searchWidget != null) {
    searchWidget.stopSearch(false);
  }
}
 

Example 4

From project iosched_3, under directory /android/src/com/google/android/apps/iosched/ui/.

Source file: HomeActivity.java

  22 
vote

@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupSearchMenuItem(Menu menu){
  MenuItem searchItem=menu.findItem(R.id.menu_search);
  if (searchItem != null && UIUtils.hasHoneycomb()) {
    SearchView searchView=(SearchView)searchItem.getActionView();
    if (searchView != null) {
      SearchManager searchManager=(SearchManager)getSystemService(SEARCH_SERVICE);
      searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    }
  }
}
 

Example 5

From project NotePad, under directory /src/com/nononsenseapps/notepad/.

Source file: NotesListFragment.java

  22 
vote

@Override public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
  mOptionsMenu=menu;
  inflater.inflate(R.menu.list_options_menu,menu);
  SearchManager searchManager=(SearchManager)activity.getSystemService(Context.SEARCH_SERVICE);
  mSearchItem=menu.findItem(R.id.menu_search);
  mSearchView=(SearchView)mSearchItem.getActionView();
  if (mSearchView != null)   mSearchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
  setupSearchView();
}
 

Example 6

From project packages_apps_Calendar, under directory /src/com/android/calendar/.

Source file: CalendarController.java

  22 
vote

private void launchSearch(long eventId,String query,ComponentName componentName){
  final SearchManager searchManager=(SearchManager)mContext.getSystemService(Context.SEARCH_SERVICE);
  final SearchableInfo searchableInfo=searchManager.getSearchableInfo(componentName);
  final Intent intent=new Intent(Intent.ACTION_SEARCH);
  intent.putExtra(SearchManager.QUERY,query);
  intent.setComponent(searchableInfo.getSearchActivity());
  intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  mContext.startActivity(intent);
}
 

Example 7

From project PinDroid, under directory /src/com/pindroid/activity/.

Source file: FragmentBaseActivity.java

  22 
vote

@TargetApi(11) public void setupSearch(Menu menu){
  if (android.os.Build.VERSION.SDK_INT >= 11) {
    SearchManager searchManager=(SearchManager)getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView=(SearchView)menu.findItem(R.id.menu_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setSubmitButtonEnabled(false);
  }
}
 

Example 8

From project FBReaderJ, under directory /src/org/geometerplus/android/fbreader/.

Source file: FBReader.java

  21 
vote

@Override public boolean onSearchRequested(){
  final FBReaderApp fbreader=(FBReaderApp)FBReaderApp.Instance();
  final FBReaderApp.PopupPanel popup=fbreader.getActivePopup();
  fbreader.hideActivePopup();
  final SearchManager manager=(SearchManager)getSystemService(SEARCH_SERVICE);
  manager.setOnCancelListener(new SearchManager.OnCancelListener(){
    public void onCancel(){
      if (popup != null) {
        fbreader.showPopup(popup.getId());
      }
      manager.setOnCancelListener(null);
    }
  }
);
  startSearch(fbreader.TextSearchPatternOption.getValue(),true,null,false);
  return true;
}
 

Example 9

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/widget/.

Source file: SearchView.java

  19 
vote

/** 
 * Constructs an intent from the given information and the search dialog state.
 * @param action Intent action.
 * @param data Intent data, or <code>null</code>.
 * @param extraData Data for {@link SearchManager#EXTRA_DATA_KEY} or <code>null</code>.
 * @param query Intent query, or <code>null</code>.
 * @param actionKey The key code of the action key that was pressed,or  {@link KeyEvent#KEYCODE_UNKNOWN} if none.
 * @param actionMsg The message for the action key that was pressed,or <code>null</code> if none.
 * @return The intent.
 */
private Intent createIntent(String action,Uri data,String extraData,String query,int actionKey,String actionMsg){
  Intent intent=new Intent(action);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  if (data != null) {
    intent.setData(data);
  }
  intent.putExtra(SearchManager.USER_QUERY,mUserQuery);
  if (query != null) {
    intent.putExtra(SearchManager.QUERY,query);
  }
  if (extraData != null) {
    intent.putExtra(SearchManager.EXTRA_DATA_KEY,extraData);
  }
  if (mAppSearchData != null) {
    intent.putExtra(SearchManager.APP_DATA,mAppSearchData);
  }
  if (actionKey != KeyEvent.KEYCODE_UNKNOWN) {
    intent.putExtra(SearchManager.ACTION_KEY,actionKey);
    intent.putExtra(SearchManager.ACTION_MSG,actionMsg);
  }
  intent.setComponent(mSearchable.getSearchActivity());
  return intent;
}
 

Example 10

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/.

Source file: SearchActivity.java

  19 
vote

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  amenTypeThin=AmenoidApp.getInstance().getAmenTypeThin();
  amenTypeBold=AmenoidApp.getInstance().getAmenTypeBold();
  Log.d(TAG,"onCreate");
  service=AmenoidApp.getInstance().getService();
  setContentView(R.layout.search);
  setTitle("Search");
  progressBar=(ProgressBar)findViewById(R.id.progress_listview);
  list=(ListView)findViewById(android.R.id.list);
  adapter=new AmenListAdapter(this,R.layout.list_item_amen,new ArrayList<Amen>());
  setListAdapter(adapter);
  Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    new LoaderAsyncTask(SearchActivity.this).executeOnThreadPool(query);
    setTitle("Search: " + query);
  }
}
 

Example 11

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/persistence/provider/.

Source file: AbstractCollectionProvider.java

  19 
vote

protected static Map<String,String> createSuggestionsMap(String idField,String column1Field,String column2Field){
  HashMap<String,String> sSuggestionProjectionMap=new HashMap<String,String>();
  sSuggestionProjectionMap.put(SearchManager.SUGGEST_COLUMN_TEXT_1,column1Field + " AS " + SearchManager.SUGGEST_COLUMN_TEXT_1);
  sSuggestionProjectionMap.put(SearchManager.SUGGEST_COLUMN_TEXT_2,column2Field + " AS " + SearchManager.SUGGEST_COLUMN_TEXT_2);
  sSuggestionProjectionMap.put(SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID,idField + " AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID);
  sSuggestionProjectionMap.put(idField,idField);
  return sSuggestionProjectionMap;
}
 

Example 12

From project android_5, under directory /src/aarddict/android/.

Source file: ArticleViewActivity.java

  19 
vote

@Override public boolean onSearchRequested(){
  Intent intent=getIntent();
  if (intent != null && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_SEARCH)) {
    Intent next=new Intent();
    next.setClass(this,LookupActivity.class);
    next.setAction(Intent.ACTION_SEARCH);
    next.putExtra(SearchManager.QUERY,intent.getStringExtra("query"));
    startActivity(next);
  }
  finish();
  return true;
}
 

Example 13

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: ProcessOutgoingCallTest.java

  19 
vote

public void onReceive(Context context,Intent intent){
  if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
    String number=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    if (LOGV)     Log.v(TAG,"Received intent " + intent + " (number = "+ number+ ".");
    if (REDIRECT_411_TO_GOOG411 && number.equals("411")) {
      setResultData("18004664411");
    }
    if (SEVEN_DIGIT_DIALING && number.length() == 7) {
      setResultData(AREACODE + number);
    }
    if (POUND_POUND_SEARCH && number.startsWith("##")) {
      Intent newIntent=new Intent(Intent.ACTION_SEARCH);
      newIntent.putExtra(SearchManager.QUERY,number.substring(2));
      newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      context.startActivity(newIntent);
      setResultData(null);
    }
    int length=number.length();
    if (BLOCK_555 && length >= 7) {
      String exchange=number.substring(length - 7,length - 4);
      Log.v(TAG,"exchange = " + exchange);
      if (exchange.equals("555")) {
        setResultData(null);
      }
    }
  }
}
 

Example 14

From project android_packages_apps_QuickSearchBox, under directory /benchmarks/src/com/android/quicksearchbox/benchmarks/.

Source file: SourceLatency.java

  19 
vote

public Cursor getSuggestions(SearchableInfo searchable,String query,int limit){
  if (searchable == null) {
    return null;
  }
  String authority=searchable.getSuggestAuthority();
  if (authority == null) {
    return null;
  }
  Uri.Builder uriBuilder=new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(authority).query("").fragment("");
  final String contentPath=searchable.getSuggestPath();
  if (contentPath != null) {
    uriBuilder.appendEncodedPath(contentPath);
  }
  uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
  String selection=searchable.getSuggestSelection();
  String[] selArgs=null;
  if (selection != null) {
    selArgs=new String[]{query};
  }
 else {
    uriBuilder.appendPath(query);
  }
  if (limit > 0) {
    uriBuilder.appendQueryParameter(SearchManager.SUGGEST_PARAMETER_LIMIT,String.valueOf(limit));
  }
  Uri uri=uriBuilder.build();
  return getContentResolver().query(uri,null,selection,selArgs,null);
}
 

Example 15

From project android_packages_apps_TouchWiz30Launcher, under directory /src/com/sec/android/app/twlauncher/.

Source file: LauncherProvider.java

  19 
vote

private ComponentName getSearchWidgetProvider(){
  ComponentName componentname=((SearchManager)mContext.getSystemService("search")).getGlobalSearchActivity();
  ComponentName componentname1;
  if (componentname == null)   componentname1=null;
 else   componentname1=getProviderInPackage(componentname.getPackageName());
  return componentname1;
}
 

Example 16

From project andstatus, under directory /src/org/andstatus/app/.

Source file: TimelineActivity.java

  19 
vote

/** 
 * Switch type of presented timeline
 */
protected void switchTimelineActivity(TimelineTypeEnum timelineType){
  Intent intent;
switch (timelineType) {
default :
    timelineType=MyDatabase.TimelineTypeEnum.HOME;
case MENTIONS:
case FAVORITES:
case HOME:
case DIRECT:
  intent=new Intent(this,TimelineActivity.class);
break;
}
intent.removeExtra(SearchManager.QUERY);
intent.putExtra(MyService.EXTRA_TIMELINE_TYPE,timelineType.save());
startActivity(intent);
}
 

Example 17

From project andtweet, under directory /src/com/xorcode/andtweet/.

Source file: TimelineActivity.java

  19 
vote

private void setTimelineType(Intent intentNew){
  int timelineType_new=intentNew.getIntExtra(AndTweetService.EXTRA_TIMELINE_TYPE,Tweets.TIMELINE_TYPE_NONE);
  if (timelineType_new != Tweets.TIMELINE_TYPE_NONE) {
    mTimelineType=timelineType_new;
  }
  mQueryString=intentNew.getStringExtra(SearchManager.QUERY);
  mSearchMode=(mQueryString != null && mQueryString.length() > 0);
  if (mSearchMode) {
  }
 else {
    mQueryString="";
  }
  if (mTimelineType == Tweets.TIMELINE_TYPE_NONE) {
    mTimelineType=Tweets.TIMELINE_TYPE_FRIENDS;
    Intent intent=getIntent();
    intent.removeExtra(SearchManager.QUERY);
    intent.removeExtra(SearchManager.APP_DATA);
    intent.putExtra(AndTweetService.EXTRA_TIMELINE_TYPE,mTimelineType);
    intent.setData(AndTweetDatabase.Tweets.CONTENT_URI);
  }
  if (Log.isLoggable(AndTweetService.APPTAG,Log.VERBOSE)) {
    Log.v(TAG,"setTimelineType; type=\"" + mTimelineType + "\"");
  }
}
 

Example 18

From project apg, under directory /src/org/thialfihar/android/apg/.

Source file: KeyListActivity.java

  19 
vote

protected void handleIntent(Intent intent){
  String searchString=null;
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    searchString=intent.getStringExtra(SearchManager.QUERY);
    if (searchString != null && searchString.trim().length() == 0) {
      searchString=null;
    }
  }
  if (searchString == null) {
    mFilterLayout.setVisibility(View.GONE);
  }
 else {
    mFilterLayout.setVisibility(View.VISIBLE);
    mFilterInfo.setText(getString(R.string.filterInfo,searchString));
  }
  if (mListAdapter != null) {
    mListAdapter.cleanup();
  }
  mListAdapter=new KeyListAdapter(this,searchString);
  mList.setAdapter(mListAdapter);
  if (Apg.Intent.IMPORT.equals(intent.getAction())) {
    if ("file".equals(intent.getScheme()) && intent.getDataString() != null) {
      mImportFilename=Uri.decode(intent.getDataString().replace("file://",""));
    }
 else {
      mImportData=intent.getStringExtra(Apg.EXTRA_TEXT);
    }
    importKeys();
  }
}
 

Example 19

From project apps-for-android, under directory /WikiNotes/src/com/google/android/wikinotes/.

Source file: WikiNotesList.java

  19 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Intent intent=getIntent();
  Uri uri=null;
  String query=null;
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    query=intent.getStringExtra(SearchManager.QUERY);
  }
 else   if (savedInstanceState != null) {
    query=savedInstanceState.getString(SearchManager.QUERY);
  }
  if (query != null && query.length() > 0) {
    uri=Uri.withAppendedPath(WikiNote.Notes.SEARCH_URI,Uri.encode(query));
  }
  if (uri == null) {
    uri=WikiNote.Notes.ALL_NOTES_URI;
  }
  Cursor c=managedQuery(uri,PROJECTION,null,null,WikiNote.Notes.DEFAULT_SORT_ORDER);
  mCursor=c;
  mHelper=new WikiActivityHelper(this);
  ListAdapter adapter=new SimpleCursorAdapter(this,android.R.layout.simple_list_item_1,mCursor,new String[]{WikiNote.Notes.TITLE},new int[]{android.R.id.text1});
  setListAdapter(adapter);
  setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
}
 

Example 20

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/io/.

Source file: LocalSearchSuggestHandler.java

  19 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=Lists.newArrayList();
  batch.add(ContentProviderOperation.newDelete(SearchSuggest.CONTENT_URI).build());
  String tag=null;
  int type;
  while ((type=parser.next()) != END_DOCUMENT) {
    if (type == START_TAG) {
      tag=parser.getName();
    }
 else     if (type == END_TAG) {
      tag=null;
    }
 else     if (type == TEXT) {
      final String text=parser.getText();
      if (Tags.WORD.equals(tag)) {
        batch.add(ContentProviderOperation.newInsert(SearchSuggest.CONTENT_URI).withValue(SearchManager.SUGGEST_COLUMN_TEXT_1,text).build());
      }
    }
  }
  return batch;
}
 

Example 21

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: CatalogueDBAdapter.java

  19 
vote

/** 
 * @param query The query string
 * @return Cursor of search suggestions
 */
public Cursor fetchSearchSuggestions(String query){
  String sql="Select * From (SELECT \"BK\" || b." + KEY_ROWID + " as "+ BaseColumns._ID+ ", b."+ KEY_TITLE+ " as "+ SearchManager.SUGGEST_COLUMN_TEXT_1+ ", b."+ KEY_TITLE+ " as "+ SearchManager.SUGGEST_COLUMN_INTENT_DATA+ " FROM "+ DB_TB_BOOKS+ " b"+ " WHERE b."+ KEY_TITLE+ " LIKE '"+ query+ "%'"+ " UNION "+ " SELECT \"AF\" || a."+ KEY_ROWID+ " as "+ BaseColumns._ID+ ", a."+ KEY_FAMILY_NAME+ " as "+ SearchManager.SUGGEST_COLUMN_TEXT_1+ ", a."+ KEY_FAMILY_NAME+ " as "+ SearchManager.SUGGEST_COLUMN_INTENT_DATA+ " FROM "+ DB_TB_AUTHORS+ " a"+ " WHERE a."+ KEY_FAMILY_NAME+ " LIKE '"+ query+ "%'"+ " UNION "+ " SELECT \"AG\" || a."+ KEY_ROWID+ " as "+ BaseColumns._ID+ ", a."+ KEY_GIVEN_NAMES+ " as "+ SearchManager.SUGGEST_COLUMN_TEXT_1+ ", a."+ KEY_GIVEN_NAMES+ " as "+ SearchManager.SUGGEST_COLUMN_INTENT_DATA+ " FROM "+ DB_TB_AUTHORS+ " a"+ " WHERE a."+ KEY_GIVEN_NAMES+ " LIKE '"+ query+ "%'"+ " UNION "+ " SELECT \"BK\" || b."+ KEY_ROWID+ " as "+ BaseColumns._ID+ ", b."+ KEY_ISBN+ " as "+ SearchManager.SUGGEST_COLUMN_TEXT_1+ ", b."+ KEY_ISBN+ " as "+ SearchManager.SUGGEST_COLUMN_INTENT_DATA+ " FROM "+ DB_TB_BOOKS+ " b"+ " WHERE b."+ KEY_ISBN+ " LIKE '"+ query+ "%'"+ " ) as zzz "+ " ORDER BY Upper("+ SearchManager.SUGGEST_COLUMN_TEXT_1+ ") "+ COLLATION;
  ;
  Cursor results=mDb.rawQuery(sql,null);
  return results;
}
 

Example 22

From project CheckIn4Me, under directory /src/com/davidivins/checkin4me/activities/.

Source file: MainTabbedContainer.java

  19 
vote

public void onCreate(Bundle saved_instance_state){
  super.onCreate(saved_instance_state);
  GeneratedResources.generate(this);
  Log.i(TAG,"" + GeneratedResources.getLayout("main"));
  setContentView(GeneratedResources.getLayout("main"));
  Resources res=getResources();
  TabHost tab_host=getTabHost();
  TabHost.TabSpec spec;
  Intent intent;
  intent=new Intent().setClass(this,ServiceConnection.class);
  spec=tab_host.newTabSpec("connect_services").setIndicator("Connect",res.getDrawable(GeneratedResources.getLayout("ic_tab_connect_services"))).setContent(intent);
  tab_host.addTab(spec);
  intent=new Intent().setClass(this,NearbyPlaces.class);
  spec=tab_host.newTabSpec("nearby_places").setIndicator("Nearby Places",res.getDrawable(GeneratedResources.getLayout("ic_tab_nearby_places"))).setContent(intent);
  tab_host.addTab(spec);
  intent=new Intent().setClass(this,Settings.class);
  spec=tab_host.newTabSpec("settings").setIndicator("Settings",res.getDrawable(GeneratedResources.getLayout("ic_tab_settings"))).setContent(intent);
  tab_host.addTab(spec);
  int tab_to_display=this.getIntent().getIntExtra("tab_to_display",-1);
  if (-1 != tab_to_display) {
    tab_host.setCurrentTab(tab_to_display);
  }
 else   if (Intent.ACTION_SEARCH.equals(getIntent().getAction()) && getIntent().getStringExtra(SearchManager.QUERY) != null) {
    Log.i(TAG,"query = " + getIntent().getStringExtra(SearchManager.QUERY));
    this.getIntent().putExtra("query",getIntent().getStringExtra(SearchManager.QUERY));
    tab_host.setCurrentTab(NEARBY_PLACES_TAB);
  }
 else {
    if (Services.getInstance(this).atLeastOneConnected())     tab_host.setCurrentTab(NEARBY_PLACES_TAB);
 else     tab_host.setCurrentTab(SERVICE_CONNECTION_TAB);
  }
  Ad ad=new Ad(this);
  ad.refreshAd();
}
 

Example 23

From project cmsandroid, under directory /src/com/zia/freshdocs/activity/.

Source file: SearchActivity.java

  19 
vote

protected void handleSearchIntent(){
  Intent queryIntent=getIntent();
  String queryAction=queryIntent.getAction();
  if (Intent.ACTION_SEARCH.equals(queryAction) && _isDirty) {
    CMIS cmis=_adapter.getCmis();
    if (cmis == null || cmis.getNetworkStatus() != NetworkStatus.OK) {
      int duration=Toast.LENGTH_SHORT;
      int error_id=cmis == null ? R.string.search_ambiguaous : R.string.offline_search_error;
      Toast toast=Toast.makeText(this,error_id,duration);
      toast.show();
      finish();
    }
 else {
      String queryString=queryIntent.getStringExtra(SearchManager.QUERY);
      search(queryString);
      _isDirty=false;
    }
  }
}
 

Example 24

From project conference-mobile-app, under directory /android-app/src/com/google/android/apps/iosched/io/.

Source file: LocalSearchSuggestHandler.java

  19 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=Lists.newArrayList();
  batch.add(ContentProviderOperation.newDelete(SearchSuggest.CONTENT_URI).build());
  String tag=null;
  int type;
  while ((type=parser.next()) != END_DOCUMENT) {
    if (type == START_TAG) {
      tag=parser.getName();
    }
 else     if (type == END_TAG) {
      tag=null;
    }
 else     if (type == TEXT) {
      final String text=parser.getText();
      if (Tags.WORD.equals(tag)) {
        batch.add(ContentProviderOperation.newInsert(SearchSuggest.CONTENT_URI).withValue(SearchManager.SUGGEST_COLUMN_TEXT_1,text).build());
      }
    }
  }
  return batch;
}
 

Example 25

From project cw-advandroid, under directory /Search/Lorem/src/com/commonsware/android/search/.

Source file: LoremSearch.java

  19 
vote

@Override ListAdapter makeMeAnAdapter(Intent intent){
  ListAdapter adapter=null;
  if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    List<String> results=searchItems(query);
    adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,results);
    setTitle("LoremSearch for: " + query);
  }
  return (adapter);
}
 

Example 26

From project cw-omnibus, under directory /Search/Lorem/src/com/commonsware/android/search/.

Source file: LoremSearch.java

  19 
vote

@Override ListAdapter makeMeAnAdapter(Intent intent){
  ListAdapter adapter=null;
  if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    List<String> results=searchItems(query);
    adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,results);
    setTitle("LoremSearch for: " + query);
  }
  return (adapter);
}
 

Example 27

From project danbo, under directory /src/us/donmai/danbooru/danbo/activity/.

Source file: TagSearchActivity.java

  19 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.setContentView(R.layout.tags);
  Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    SearchTask task=new SearchTask();
    task.execute(query);
  }
}
 

Example 28

From project danbooru-gallery-android, under directory /src/tw/idv/palatis/danboorugallery/.

Source file: MainActivity.java

  19 
vote

private void handleIntent(Intent intent){
  boolean dosearch=false;
  String query="";
  if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
    query=intent.getStringExtra(SearchManager.QUERY).replace(' ','_');
    dosearch=true;
  }
 else   if (intent.getAction().equals(Intent.ACTION_VIEW)) {
    Uri uri=intent.getData();
    if (uri != null) {
      query=uri.toString();
      dosearch=true;
    }
  }
  if (dosearch) {
    Toast.makeText(this,String.format(getString(R.string.main_query),query),Toast.LENGTH_SHORT).show();
    if (fetcher.setTags(query)) {
      fetcher.setPage(1);
      fetcher.cancel();
      posts.clear();
      adapter.cancelAll();
      adapter.notifyDataSetChanged();
    }
  }
  setIntent(intent);
}
 

Example 29

From project dccsched, under directory /src/com/underhilllabs/dccsched/io/.

Source file: LocalSearchSuggestHandler.java

  19 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=Lists.newArrayList();
  batch.add(ContentProviderOperation.newDelete(SearchSuggest.CONTENT_URI).build());
  String tag=null;
  int type;
  while ((type=parser.next()) != END_DOCUMENT) {
    if (type == START_TAG) {
      tag=parser.getName();
    }
 else     if (type == END_TAG) {
      tag=null;
    }
 else     if (type == TEXT) {
      final String text=parser.getText();
      if (Tags.WORD.equals(tag)) {
        batch.add(ContentProviderOperation.newInsert(SearchSuggest.CONTENT_URI).withValue(SearchManager.SUGGEST_COLUMN_TEXT_1,text).build());
      }
    }
  }
  return batch;
}
 

Example 30

From project dcnyc10-android, under directory /android/src/com/lullabot/android/apps/iosched/io/.

Source file: LocalSearchSuggestHandler.java

  19 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=Lists.newArrayList();
  batch.add(ContentProviderOperation.newDelete(SearchSuggest.CONTENT_URI).build());
  String tag=null;
  int type;
  while ((type=parser.next()) != END_DOCUMENT) {
    if (type == START_TAG) {
      tag=parser.getName();
    }
 else     if (type == END_TAG) {
      tag=null;
    }
 else     if (type == TEXT) {
      final String text=parser.getText();
      if (Tags.WORD.equals(tag)) {
        batch.add(ContentProviderOperation.newInsert(SearchSuggest.CONTENT_URI).withValue(SearchManager.SUGGEST_COLUMN_TEXT_1,text).build());
      }
    }
  }
  return batch;
}
 

Example 31

From project DeliciousDroid, under directory /src/com/deliciousdroid/providers/.

Source file: BookmarkContentProvider.java

  19 
vote

@Override public String getType(Uri uri){
switch (sURIMatcher.match(uri)) {
case Bookmarks:
    return Bookmark.CONTENT_TYPE;
case SearchSuggest:
  return SearchManager.SUGGEST_MIME_TYPE;
case Tags:
return Tag.CONTENT_TYPE;
case Bundles:
return Bundle.CONTENT_TYPE;
default :
throw new IllegalArgumentException("Unknown URL " + uri);
}
}
 

Example 32

From project devoxx-france-android-in-fine, under directory /src/com/infine/android/devoxx/ui/.

Source file: SearchActivity.java

  19 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Intent intent=getIntent();
  mQuery=intent.getStringExtra(SearchManager.QUERY);
  setContentView(R.layout.activity_search);
  final CharSequence title=getString(R.string.title_search_query,mQuery);
  getActivityHelper().setupActionBar(getTitle(),0);
  getActivityHelper().setActionBarTitle(title);
  mTabHost=(TabHost)findViewById(android.R.id.tabhost);
  mTabWidget=(TabWidget)findViewById(android.R.id.tabs);
  mTabHost.setup();
  setupSessionsTab();
  setupSpeakersTab();
}
 

Example 33

From project Diktofon, under directory /app/src/kaljurand_at_gmail_dot_com/diktofon/activity/.

Source file: TransActivity.java

  19 
vote

private void handleIntent(Intent intent){
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    if (query != null) {
      query=query.replace('\u00a6','|');
      SearchRecentSuggestions suggestions=new SearchRecentSuggestions(this,SearchSuggestionsProvider.AUTHORITY,SearchSuggestionsProvider.MODE);
      suggestions.saveRecentQuery(query,null);
      mQuery=query;
    }
  }
}
 

Example 34

From project DiscogsForAndroid, under directory /src/com/discogs/activities/.

Source file: SearchActivity.java

  19 
vote

@Override public void onNewIntent(final Intent newIntent){
  super.onNewIntent(newIntent);
  final Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    query=intent.getStringExtra(SearchManager.QUERY);
    SearchRecentSuggestions suggestions=new SearchRecentSuggestions(this,DiscogsSuggestionProvider.AUTHORITY,DiscogsSuggestionProvider.MODE);
    suggestions.saveRecentQuery(query,null);
    query=StringUtils.replace(query," ","_");
    Thread thread=new Thread(new Runnable(){
      public void run(){
        results=engine.search(query,1);
        handler.post(new Runnable(){
          @Override public void run(){
            showUI();
          }
        }
);
      }
    }
);
    thread.start();
  }
}
 

Example 35

From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/.

Source file: SearchActivity.java

  19 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  app=(MPDApplication)getApplication();
  setContentView(R.layout.browse);
  loadingView=findViewById(R.id.loadingLayout);
  loadingTextView=(TextView)findViewById(R.id.loadingText);
  noResultView=findViewById(R.id.noResultLayout);
  loadingView.setVisibility(View.VISIBLE);
  loadingTextView.setText(R.string.loading);
  final Intent queryIntent=getIntent();
  final String queryAction=queryIntent.getAction();
  if (Intent.ACTION_SEARCH.equals(queryAction)) {
    searchKeywords=queryIntent.getStringExtra(SearchManager.QUERY).trim();
  }
 else {
    return;
  }
  setTitle(getTitle() + " : " + searchKeywords);
  registerForContextMenu(getListView());
  updateList();
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 

Example 36

From project dreamDroid, under directory /src/net/reichholf/dreamdroid/activities/.

Source file: SimpleFragmentActivity.java

  19 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  setProgressBarIndeterminateVisibility(false);
  if (getSupportActionBar() != null)   getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  mFragment=null;
  boolean initFragment=true;
  if (savedInstanceState != null) {
    mFragment=getSupportFragmentManager().findFragmentById(R.id.content);
    initFragment=false;
  }
  Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction()) && savedInstanceState == null) {
    Bundle args=new Bundle();
    args.putString(SearchManager.QUERY,intent.getStringExtra(SearchManager.QUERY));
    if (DreamDroid.search(this,args)) {
      finish();
      return;
    }
 else {
      mFragment=new EpgSearchFragment();
      mFragment.setArguments(args);
    }
  }
  initViews(initFragment);
}
 

Example 37

From project eoit, under directory /EOIT/src/fr/eoit/activity/.

Source file: ItemListActivity.java

  19 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.itemlist);
  Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    query=intent.getStringExtra(SearchManager.QUERY);
    showResults();
  }
 else   if (Intent.ACTION_VIEW.equals(intent.getAction())) {
    Intent itemIntent=new Intent(this,ItemInfo2Activity.class);
    itemIntent.setData(intent.getData());
    startActivity(itemIntent);
    finish();
  }
 else {
    if (intent.getData() == null) {
      intent.setData(Item.CONTENT_URI);
    }
    adapter=new AmazingSimpleCursorAdapter(this,R.layout.row,dataColumns,viewIDs);
    adapter.setViewBinder(new ItemListViewBinder());
    AmazingListView itemListView=(AmazingListView)findViewById(R.id.ITEM_LIST);
    itemListView.setOnItemClickListener(new ItemOnItemListClickListener());
    itemListView.setPinnedHeaderView(LayoutInflater.from(this).inflate(R.layout.row_header,itemListView,false));
    itemListView.setAdapter(adapter);
    getSupportLoaderManager().initLoader(FAVORITE_LOADER_ID,null,this);
  }
}
 

Example 38

From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/.

Source file: SearchActivity.java

  19 
vote

protected boolean startSearch(){
  if (!TextUtils.isEmpty(initialQuery)) {
    Intent i=new Intent(this,SearchResultActivity.class);
    i.putExtra(SearchManager.QUERY,initialQuery);
    startActivity(i);
  }
 else   if (TextUtils.isEmpty(initialQuery)) {
    Toast.makeText(this,getResources().getString(R.string.search_box_null),Toast.LENGTH_SHORT).show();
    return false;
  }
  return false;
}
 

Example 39

From project filemanager, under directory /FileManager/src/org/openintents/filemanager/search/.

Source file: SearchableActivity.java

  19 
vote

private void handleIntent(){
  Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    setTitle(query);
    String path=null;
    if (intent.getBundleExtra(SearchManager.APP_DATA) != null)     path=intent.getBundleExtra(SearchManager.APP_DATA).getString(FileManagerIntents.EXTRA_SEARCH_INIT_PATH);
    SearchRecentSuggestions suggestions=new SearchRecentSuggestions(this,RecentsSuggestionsProvider.AUTHORITY,RecentsSuggestionsProvider.MODE);
    suggestions.saveRecentQuery(query,null);
    lbm.registerReceiver(new BroadcastReceiver(){
      @Override public void onReceive(      Context context,      Intent intent){
        setProgressBarIndeterminateVisibility(false);
      }
    }
,new IntentFilter(FileManagerIntents.ACTION_SEARCH_FINISHED));
    lbm.registerReceiver(new BroadcastReceiver(){
      @Override public void onReceive(      Context context,      Intent intent){
        setProgressBarIndeterminateVisibility(true);
      }
    }
,new IntentFilter(FileManagerIntents.ACTION_SEARCH_STARTED));
    searchResults=getSearchResults();
    setListAdapter(new SearchListAdapter(this,searchResults));
    Intent in=new Intent(this,SearchService.class);
    in.putExtra(FileManagerIntents.EXTRA_SEARCH_INIT_PATH,path);
    in.putExtra(FileManagerIntents.EXTRA_SEARCH_QUERY,query);
    startService(in);
  }
 else   if (Intent.ACTION_VIEW.equals(intent.getAction())) {
    browse(intent.getData());
  }
 else   setTitle(R.string.query_error);
}
 

Example 40

From project framework_base_policy, under directory /src/com/android/internal/policy/impl/.

Source file: PhoneFallbackEventHandler.java

  19 
vote

SearchManager getSearchManager(){
  if (mSearchManager == null) {
    mSearchManager=(SearchManager)mContext.getSystemService(Context.SEARCH_SERVICE);
  }
  return mSearchManager;
}
 

Example 41

From project gddsched2, under directory /trunk/android/src/com/google/android/apps/iosched2/io/.

Source file: LocalSearchSuggestHandler.java

  19 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=Lists.newArrayList();
  batch.add(ContentProviderOperation.newDelete(SearchSuggest.CONTENT_URI).build());
  String tag=null;
  int type;
  while ((type=parser.next()) != END_DOCUMENT) {
    if (type == START_TAG) {
      tag=parser.getName();
    }
 else     if (type == END_TAG) {
      tag=null;
    }
 else     if (type == TEXT) {
      final String text=parser.getText();
      if (Tags.WORD.equals(tag)) {
        batch.add(ContentProviderOperation.newInsert(SearchSuggest.CONTENT_URI).withValue(SearchManager.SUGGEST_COLUMN_TEXT_1,text).build());
      }
    }
  }
  return batch;
}
 

Example 42

From project Gibberbot, under directory /src/info/guardianproject/otr/app/im/app/.

Source file: ContactListActivity.java

  19 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  LayoutInflater inflate=getLayoutInflater();
  mContactListView=(ContactListView)inflate.inflate(R.layout.contact_list_view,null);
  mFilterView=(ContactListFilterView)getLayoutInflater().inflate(R.layout.contact_list_filter_view,null);
  mFilterView.setActivity(this);
  mFilterView.getListView().setOnCreateContextMenuListener(this);
  Intent intent=getIntent();
  mAccountId=intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID,-1);
  if (mAccountId == -1) {
    finish();
    return;
  }
  setupActionBarList(mAccountId);
  mApp=ImApp.getApplication(this);
  initAccount();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    if (mIsFiltering) {
      String filterText=intent.getStringExtra(SearchManager.QUERY);
      mFilterView.doFilter(filterText);
    }
  }
}
 

Example 43

From project gmarks-android, under directory /src/main/java/org/thomnichols/android/gmarks/.

Source file: BookmarksListActivity.java

  19 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
  getListView().setOnItemLongClickListener(this.longClickListener);
  this.currentSort=Prefs.get(this).getInt(Prefs.KEY_BOOKMARKS_SORT_PREF,SORT_MODIFIED);
  setTitle(R.string.bookmarks_activity);
  final Intent intent=getIntent();
  if (intent.getData() == null)   intent.setData(Bookmark.CONTENT_URI);
  Uri uri=intent.getData();
  if (uri == null)   intent.setData(Bookmark.CONTENT_URI);
  final String action=intent.getAction();
  if (Intent.ACTION_PICK.equals(action)) {
    setTitle(R.string.choose_bookmark);
  }
 else   if (Intent.ACTION_VIEW.equals(action) && uri.getScheme().startsWith("http")) {
    startActivity(new Intent(Intent.ACTION_VIEW,uri));
    finish();
    return;
  }
 else   if (Intent.ACTION_SEARCH.equals(action)) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    uri=uri.buildUpon().appendPath("search").appendQueryParameter("q",query).build();
    intent.setData(uri);
    this.setTitle(getString(R.string.search_results_title,query));
  }
 else {
    String labelName=uri.getQueryParameter("label");
    if (labelName != null)     this.setTitle(getString(R.string.label_results_title,labelName));
  }
  Cursor cursor=getCursorFromIntent(intent);
  SimpleCursorAdapter adapter=new SimpleCursorAdapter(this,R.layout.bookmarkslist_item,cursor,new String[]{Bookmark.Columns.TITLE,Bookmark.Columns.HOST},new int[]{R.id.title,R.id.host});
  setListAdapter(adapter);
}
 

Example 44

From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/viewer/.

Source file: TrackList.java

  19 
vote

@Override public boolean onCreateOptionsMenu(Menu menu){
  boolean result=super.onCreateOptionsMenu(menu);
  menu.add(ContextMenu.NONE,MENU_SEARCH,ContextMenu.NONE,android.R.string.search_go).setIcon(android.R.drawable.ic_search_category_default).setAlphabeticShortcut(SearchManager.MENU_KEY);
  menu.add(ContextMenu.NONE,MENU_VACUUM,ContextMenu.NONE,R.string.menu_vacuum).setIcon(android.R.drawable.ic_menu_crop);
  menu.add(ContextMenu.NONE,MENU_PICKER,ContextMenu.NONE,R.string.menu_picker).setIcon(android.R.drawable.ic_menu_add);
  return result;
}
 

Example 45

From project huiswerk, under directory /print/zxing-1.6/android/src/com/google/zxing/client/android/result/.

Source file: ResultHandler.java

  19 
vote

final void openGoogleShopper(String query){
  try {
    activity.getPackageManager().getPackageInfo(GOOGLE_SHOPPER_PACKAGE,0);
    Intent intent=new Intent(Intent.ACTION_SEARCH);
    intent.setClassName(GOOGLE_SHOPPER_PACKAGE,GOOGLE_SHOPPER_ACTIVITY);
    intent.putExtra(SearchManager.QUERY,query);
    activity.startActivity(intent);
  }
 catch (  PackageManager.NameNotFoundException e) {
    AlertDialog.Builder builder=new AlertDialog.Builder(activity);
    builder.setTitle(R.string.msg_google_shopper_missing);
    builder.setMessage(R.string.msg_install_google_shopper);
    builder.setIcon(R.drawable.shopper_icon);
    builder.setPositiveButton(R.string.button_ok,shopperMarketListener);
    builder.setNegativeButton(R.string.button_cancel,null);
    builder.show();
  }
}
 

Example 46

From project iosched, under directory /android/src/com/google/android/apps/iosched/io/.

Source file: LocalSearchSuggestHandler.java

  19 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=Lists.newArrayList();
  batch.add(ContentProviderOperation.newDelete(SearchSuggest.CONTENT_URI).build());
  String tag=null;
  int type;
  while ((type=parser.next()) != END_DOCUMENT) {
    if (type == START_TAG) {
      tag=parser.getName();
    }
 else     if (type == END_TAG) {
      tag=null;
    }
 else     if (type == TEXT) {
      final String text=parser.getText();
      if (Tags.WORD.equals(tag)) {
        batch.add(ContentProviderOperation.newInsert(SearchSuggest.CONTENT_URI).withValue(SearchManager.SUGGEST_COLUMN_TEXT_1,text).build());
      }
    }
  }
  return batch;
}
 

Example 47

From project iosched2011, under directory /android/src/com/google/android/apps/iosched/io/.

Source file: LocalSearchSuggestHandler.java

  19 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=Lists.newArrayList();
  batch.add(ContentProviderOperation.newDelete(SearchSuggest.CONTENT_URI).build());
  String tag=null;
  int type;
  while ((type=parser.next()) != END_DOCUMENT) {
    if (type == START_TAG) {
      tag=parser.getName();
    }
 else     if (type == END_TAG) {
      tag=null;
    }
 else     if (type == TEXT) {
      final String text=parser.getText();
      if (Tags.WORD.equals(tag)) {
        batch.add(ContentProviderOperation.newInsert(SearchSuggest.CONTENT_URI).withValue(SearchManager.SUGGEST_COLUMN_TEXT_1,text).build());
      }
    }
  }
  return batch;
}
 

Example 48

From project iosched_1, under directory /src/com/google/android/apps/iosched/io/.

Source file: LocalSearchSuggestHandler.java

  19 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=Lists.newArrayList();
  batch.add(ContentProviderOperation.newDelete(SearchSuggest.CONTENT_URI).build());
  String tag=null;
  int type;
  while ((type=parser.next()) != END_DOCUMENT) {
    if (type == START_TAG) {
      tag=parser.getName();
    }
 else     if (type == END_TAG) {
      tag=null;
    }
 else     if (type == TEXT) {
      final String text=parser.getText();
      if (Tags.WORD.equals(tag)) {
        batch.add(ContentProviderOperation.newInsert(SearchSuggest.CONTENT_URI).withValue(SearchManager.SUGGEST_COLUMN_TEXT_1,text).build());
      }
    }
  }
  return batch;
}
 

Example 49

From project iosched_2, under directory /android/src/com/google/android/apps/iosched/io/.

Source file: LocalSearchSuggestHandler.java

  19 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=Lists.newArrayList();
  batch.add(ContentProviderOperation.newDelete(SearchSuggest.CONTENT_URI).build());
  String tag=null;
  int type;
  while ((type=parser.next()) != END_DOCUMENT) {
    if (type == START_TAG) {
      tag=parser.getName();
    }
 else     if (type == END_TAG) {
      tag=null;
    }
 else     if (type == TEXT) {
      final String text=parser.getText();
      if (Tags.WORD.equals(tag)) {
        batch.add(ContentProviderOperation.newInsert(SearchSuggest.CONTENT_URI).withValue(SearchManager.SUGGEST_COLUMN_TEXT_1,text).build());
      }
    }
  }
  return batch;
}
 

Example 50

From project Jota-Text-Editor, under directory /src/jp/sblo/pandora/jota/.

Source file: Main.java

  19 
vote

private void searchWord(String substr){
  Intent intent=new Intent(Intent.ACTION_SEARCH);
  intent.putExtra(SearchManager.QUERY,substr);
  try {
    Intent pickIntent=new Intent(Main.this,ActivityPicker.class);
    pickIntent.putExtra(Intent.EXTRA_INTENT,intent);
    mReservedIntent=intent;
    mReservedRequestCode=REQUESTCODE_SEARCHBYINTENT;
    startActivityForResult(pickIntent,REQUESTCODE_APPCHOOSER);
  }
 catch (  Exception e) {
  }
}
 

Example 51

From project k-9, under directory /src/com/fsck/k9/activity/.

Source file: MessageList.java

  19 
vote

public static void actionHandle(Context context,String title,String queryString,boolean integrate,Flag[] flags,Flag[] forbiddenFlags){
  Intent intent=new Intent(context,MessageList.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
  intent.putExtra(SearchManager.QUERY,queryString);
  if (flags != null) {
    intent.putExtra(EXTRA_QUERY_FLAGS,Utility.combine(flags,','));
  }
  if (forbiddenFlags != null) {
    intent.putExtra(EXTRA_FORBIDDEN_FLAGS,Utility.combine(forbiddenFlags,','));
  }
  intent.putExtra(EXTRA_INTEGRATE,integrate);
  intent.putExtra(EXTRA_TITLE,title);
  context.startActivity(intent);
}
 

Example 52

From project K6nele, under directory /app/src/ee/ioc/phon/android/speak/.

Source file: SpeechRecognitionService.java

  19 
vote

/** 
 * <p>Returns the transcription results (matches) to the caller, or sends them to the pending intent. In the latter case we also display a toast-message with the transcription. Note that we assume that the given list of matches contains at least one element.</p> TODO: the pending intent result code is currently set to 1234 (don't know what this means)
 * @param matches transcription results (one or more)
 * @param listener listener that receives the matches
 * @throws RemoteException 
 */
private void returnOrForwardMatches(ArrayList<String> matches,Callback listener) throws RemoteException {
  int maxResults=mExtras.getInt(RecognizerIntent.EXTRA_MAX_RESULTS);
  if (maxResults > 0 && matches.size() > maxResults) {
    matches.subList(maxResults,matches.size()).clear();
  }
  PendingIntent pendingIntent=Utils.getPendingIntent(mExtras);
  if (pendingIntent == null) {
    Bundle bundle=new Bundle();
    bundle.putStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION,matches);
    listener.results(bundle);
  }
 else {
    Bundle bundle=mExtras.getBundle(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE);
    if (bundle == null) {
      bundle=new Bundle();
    }
    String match=matches.get(0);
    Intent intent=new Intent();
    intent.putExtras(bundle);
    intent.putExtra(SearchManager.QUERY,match);
    intent.putStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS,matches);
    try {
      pendingIntent.send(this,1234,intent);
    }
 catch (    CanceledException e) {
    }
  }
}
 

Example 53

From project keepassdroid, under directory /src/com/keepassdroid/search/.

Source file: SearchResults.java

  19 
vote

private String getSearchStr(Intent queryIntent){
  final String queryAction=queryIntent.getAction();
  if (Intent.ACTION_SEARCH.equals(queryAction)) {
    return queryIntent.getStringExtra(SearchManager.QUERY);
  }
  return "";
}
 

Example 54

From project maven-android-plugin-samples, under directory /apidemos-android-10/application/src/main/java/com/example/android/apis/app/.

Source file: SearchInvoke.java

  19 
vote

/** 
 * Called when your activity's options menu needs to be updated. 
 */
@Override public boolean onPrepareOptionsMenu(Menu menu){
  super.onPrepareOptionsMenu(menu);
  MenuItem item;
  menu.removeItem(0);
  menu.removeItem(1);
switch (mMenuMode.getSelectedItemPosition()) {
case MENUMODE_SEARCH_KEY:
    item=menu.add(0,0,0,"(Search Key)");
  break;
case MENUMODE_MENU_ITEM:
item=menu.add(0,0,0,"Search");
item.setAlphabeticShortcut(SearchManager.MENU_KEY);
break;
case MENUMODE_TYPE_TO_SEARCH:
item=menu.add(0,0,0,"(Type-To-Search)");
break;
case MENUMODE_DISABLED:
item=menu.add(0,0,0,"(Disabled)");
break;
}
item=menu.add(0,1,0,"Clear History");
return true;
}
 

Example 55

From project MIT-Mobile-for-Android, under directory /src/edu/mit/mitmobile2/.

Source file: CommonActions.java

  19 
vote

public static void searchMap(Context context,String mapQuery){
  Intent intent=new Intent(context,MITMapActivity.class);
  intent.setAction(Intent.ACTION_SEARCH);
  intent.putExtra(SearchManager.QUERY,mapQuery);
  context.startActivity(intent);
}
 

Example 56

From project mixare, under directory /src/org/mixare/.

Source file: MixListView.java

  19 
vote

private void handleIntent(Intent intent){
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    doMixSearch(query);
  }
}
 

Example 57

From project Mobile-Tour-Guide, under directory /zxing-2.0/android/src/com/google/zxing/client/android/result/.

Source file: ResultHandler.java

  19 
vote

final void openGoogleShopper(String query){
  Intent intent=new Intent(Intent.ACTION_SEARCH);
  intent.setClassName(GOOGLE_SHOPPER_PACKAGE,GOOGLE_SHOPPER_ACTIVITY);
  intent.putExtra(SearchManager.QUERY,query);
  PackageManager pm=activity.getPackageManager();
  Collection<?> availableApps=pm.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
  if (availableApps != null && !availableApps.isEmpty()) {
    activity.startActivity(intent);
  }
 else {
    AlertDialog.Builder builder=new AlertDialog.Builder(activity);
    builder.setTitle(R.string.msg_google_shopper_missing);
    builder.setMessage(R.string.msg_install_google_shopper);
    builder.setIcon(R.drawable.shopper_icon);
    builder.setPositiveButton(R.string.button_ok,shopperMarketListener);
    builder.setNegativeButton(R.string.button_cancel,null);
    builder.show();
  }
}
 

Example 58

From project mp3tunes-android, under directory /src/com/mp3tunes/android/activity/.

Source file: AlbumBrowser.java

  19 
vote

void doSearch(){
  CharSequence title=null;
  String query=null;
  Intent i=new Intent();
  i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
  title=mCurrentAlbumName;
  i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM,mCurrentAlbumName);
  i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS,MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE);
  i.putExtra(SearchManager.QUERY,query);
  startActivity(Intent.createChooser(i,title));
}
 

Example 59

From project mWater-Android-App, under directory /android/src/co/mwater/clientapp/ui/.

Source file: SourceListActivity.java

  19 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.source_list);
  actionBar=getSupportActionBar();
  adapter=new SimpleCursorAdapter(this,R.layout.source_row,null,new String[]{"code","name","desc"},new int[]{R.id.code,R.id.name,R.id.desc},Adapter.NO_SELECTION);
  ListView listView=(ListView)findViewById(R.id.list);
  listView.setAdapter(adapter);
  listView.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(    AdapterView<?> a,    View v,    int position,    long id){
      SourceListActivity.this.onItemClick(id);
    }
  }
);
  Intent intent=getIntent();
  if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    this.query=query;
  }
  LocationManager locationManager=(LocationManager)getSystemService(LOCATION_SERVICE);
  locationFinder=new LocationFinder(locationManager);
  if (locationFinder.getLastLocation() != null)   getSupportLoaderManager().initLoader(LOADER_ID,null,this);
 else {
    progressDialog=ProgressDialog.show(this,"Sources","Waiting for location...");
  }
}
 

Example 60

From project onebusaway-android, under directory /src/com/joulespersecond/seattlebusbot/.

Source file: SearchActivity.java

  19 
vote

private void handleIntent(Intent intent){
  if (Intent.ACTION_VIEW.equals(intent.getAction())) {
  }
 else   if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    String query=intent.getStringExtra(SearchManager.QUERY);
    doSearch(query);
  }
}
 

Example 61

From project OpenBike, under directory /src/fr/openbike/android/database/.

Source file: OpenBikeDBAdapter.java

  19 
vote

public Cursor getStationsMatches(String query,String[] columns){
  String table=STATIONS_VIRTUAL_TABLE;
  try {
    Integer.parseInt(query);
    table=BaseColumns._ID;
  }
 catch (  NumberFormatException ex) {
  }
  query+="*";
  String s="SELECT vs._id, vs._id as " + SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID + ", 'n? ' || vs._id as "+ SearchManager.SUGGEST_COLUMN_TEXT_2+ ", vs.name as "+ SearchManager.SUGGEST_COLUMN_TEXT_1+ " FROM"+ " virtual_stations vs WHERE "+ table+ " MATCH ? AND vs.network = "+ mPreferences.getInt(AbstractPreferencesActivity.NETWORK_PREFERENCE,AbstractPreferencesActivity.NO_NETWORK)+ ";";
  Cursor cursor=mDb.rawQuery(s,new String[]{query});
  if (cursor == null) {
    return null;
  }
  return cursor;
}
 

Example 62

From project Orweb, under directory /src/info/guardianproject/browser/.

Source file: Browser.java

  19 
vote

@Override protected void onNewIntent(Intent intent){
  String action=intent.getAction();
  if (Intent.ACTION_SEARCH.equals(action)) {
    String url=intent.getStringExtra(SearchManager.QUERY);
    Message msg=new Message();
    msg.getData().putString("url",url);
    mLoadHandler.sendMessage(msg);
  }
 else   if (Intent.ACTION_VIEW.equals(action)) {
    String url=intent.getDataString();
    url=smartUrlFilter(url);
    Message msg=new Message();
    msg.getData().putString("url",url);
    mLoadHandler.sendMessage(msg);
  }
}
 

Example 63

From project packages_apps_Phone_1, under directory /src/com/android/phone/.

Source file: ProcessOutgoingCallTest.java

  19 
vote

public void onReceive(Context context,Intent intent){
  if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
    String number=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    if (LOGV)     Log.v(TAG,"Received intent " + intent + " (number = "+ number+ ".");
    if (REDIRECT_411_TO_GOOG411 && number.equals("411")) {
      setResultData("18004664411");
    }
    if (SEVEN_DIGIT_DIALING && number.length() == 7) {
      setResultData(AREACODE + number);
    }
    if (POUND_POUND_SEARCH && number.startsWith("##")) {
      Intent newIntent=new Intent(Intent.ACTION_SEARCH);
      newIntent.putExtra(SearchManager.QUERY,number.substring(2));
      newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      context.startActivity(newIntent);
      setResultData(null);
    }
    int length=number.length();
    if (BLOCK_555 && length >= 7) {
      String exchange=number.substring(length - 7,length - 4);
      Log.v(TAG,"exchange = " + exchange);
      if (exchange.equals("555")) {
        setResultData(null);
      }
    }
  }
}
 

Example 64

From project PartyWare, under directory /android/src/com/google/zxing/client/android/result/.

Source file: ResultHandler.java

  19 
vote

final void openGoogleShopper(String query){
  try {
    activity.getPackageManager().getPackageInfo(GOOGLE_SHOPPER_PACKAGE,0);
    Intent intent=new Intent(Intent.ACTION_SEARCH);
    intent.setClassName(GOOGLE_SHOPPER_PACKAGE,GOOGLE_SHOPPER_ACTIVITY);
    intent.putExtra(SearchManager.QUERY,query);
    activity.startActivity(intent);
  }
 catch (  PackageManager.NameNotFoundException e) {
    AlertDialog.Builder builder=new AlertDialog.Builder(activity);
    builder.setTitle(R.string.msg_google_shopper_missing);
    builder.setMessage(R.string.msg_install_google_shopper);
    builder.setIcon(R.drawable.shopper_icon);
    builder.setPositiveButton(R.string.button_ok,shopperMarketListener);
    builder.setNegativeButton(R.string.button_cancel,null);
    builder.show();
  }
}
 

Example 65

From project persistence, under directory /src/main/java/com/codeslap/persistence/suggestions/.

Source file: SuggestionsCursor.java

  19 
vote

SuggestionsCursor(List<SuggestionInfo> suggestionInfos){
  mSuggestionInfos.addAll(suggestionInfos);
  if (suggestionInfos.size() > 0 && suggestionInfos.get(0).getDescription() != null) {
    COLUMNS=new String[]{BaseColumns._ID,SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID,SearchManager.SUGGEST_COLUMN_TEXT_1,SearchManager.SUGGEST_COLUMN_TEXT_2};
  }
 else {
    COLUMNS=new String[]{BaseColumns._ID,SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID,SearchManager.SUGGEST_COLUMN_TEXT_1};
  }
}