Example usage for android.app SearchManager QUERY

List of usage examples for android.app SearchManager QUERY

Introduction

In this page you can find the example usage for android.app SearchManager QUERY.

Prototype

String QUERY

To view the source code for android.app SearchManager QUERY.

Click Source Link

Document

Intent extra data key: Use this key with android.content.Intent#getStringExtra content.Intent.getStringExtra() to obtain the query string from Intent.ACTION_SEARCH.

Usage

From source file:com.example.android.shuttershock.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // The action bar home/up action should open or close the drawer.
    // ActionBarDrawerToggle will take care of this.
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }// w w w  .ja va2 s .  co  m
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.take_pic:
        Toast.makeText(getApplicationContext(), "button is working", Toast.LENGTH_LONG).show();
        takePic();
        //galleryAddPic();
        return true;
    case R.id.upload:
        /* Intent intentx = new Intent();
         intentx.setType("image/*");
         intentx.setAction(Intent.ACTION_GET_CONTENT);
         startActivityForResult(
            Intent.createChooser(intentx, "Select Picture"),
            SELECT_PICTURE);*/

        final Intent galleryIntent = new Intent(Intent.ACTION_PICK,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

        startActivityForResult(galleryIntent, SELECT_PICTURE);
        //galleryAddPic();
        return true;
    case R.id.look:
        LongOperation longOperation = new LongOperation(this);
        longOperation.execute();
        // readContacts();
        return true;
    case R.id.action_websearch:
        // create intent to perform web search for this filter
        Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, getActionBar().getTitle());
        // catch event that there's no activity to handle intent
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        } else {
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java

private void handleIntent(Intent intent) {
    //  ? ? /*from   w  w w.jav a2s. com*/
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY); //  ?
        //  doMixSearch(query);    //  
    } else if (intent.getExtras() != null) {
        FCMMessagingService.clear(intent.getStringExtra("traceID"));
        Intent traceIntent = new Intent(this, TraceActivity.class);
        traceIntent.putExtras(intent.getExtras());
        topLayoutOnMixView.mainArView.setVisibility(View.GONE);
        startActivityForResult(traceIntent, SHOW_TRACE);
    }
}

From source file:android.com.example.contactslist.ui.ContactsListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (!TextUtils.isEmpty(mSearchTerm)) {
        // Saves the current search string
        outState.putString(SearchManager.QUERY, mSearchTerm);

        // Saves the currently selected contact
        outState.putInt(STATE_PREVIOUSLY_SELECTED_KEY, getListView().getCheckedItemPosition());
    }/*from  w ww  .  j ava  2s .  c  om*/
}

From source file:nl.sogeti.android.gpstracker.viewer.TrackList.java

private Cursor doSearchWithIntent(final Intent queryIntent) {
    final String queryString = queryIntent.getStringExtra(SearchManager.QUERY);
    Cursor cursor = managedQuery(Tracks.CONTENT_URI,
            new String[] { Tracks._ID, Tracks.NAME, Tracks.CREATION_TIME }, "name LIKE ?",
            new String[] { "%" + queryString + "%" }, null);
    return cursor;
}

From source file:com.andrew.apollo.ui.activities.ProfileActivity.java

/**
 * Searches Google for the artist or album
 *///from   w  ww.  j a va  2 s  .  c  o  m
public void googleSearch() {
    String query = mProfileName;
    if (isArtist()) {
        query = mArtistName;
    } else if (isAlbum()) {
        query = mProfileName + " " + mArtistName;
    }
    final Intent googleSearch = new Intent(Intent.ACTION_WEB_SEARCH);
    googleSearch.putExtra(SearchManager.QUERY, query);
    startActivity(googleSearch);
    // Make sure the notification starts.
    MusicUtils.startBackgroundService(this);
}

From source file:com.boko.vimusic.ui.activities.ProfileActivity.java

/**
 * Searches Google for the artist or album
 *//*from  w ww .  j a v a 2  s.  c o  m*/
public void googleSearch() {
    String query = mProfileName;
    if (isArtist()) {
        query = mArtistName;
    } else if (isAlbum()) {
        query = mProfileName + " " + mArtistName;
    }
    final Intent googleSearch = new Intent(Intent.ACTION_WEB_SEARCH);
    googleSearch.putExtra(SearchManager.QUERY, query);
    startActivity(googleSearch);
}

From source file:com.google.zxing.client.android.result.ResultHandler.java

final void openGoogleShopper(String query) {

    // Construct Intent to launch Shopper
    Intent intent = new Intent(Intent.ACTION_SEARCH);
    intent.setClassName(GOOGLE_SHOPPER_PACKAGE, GOOGLE_SHOPPER_ACTIVITY);
    intent.putExtra(SearchManager.QUERY, query);

    // Is it available?
    PackageManager pm = activity.getPackageManager();
    Collection<?> availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);

    if (availableApps != null && !availableApps.isEmpty()) {
        // If something can handle it, start it
        activity.startActivity(intent);/* w w  w .j a v  a 2s. c o m*/
    } else {
        // Otherwise offer to install it from Market.
        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();
    }
}

From source file:com.nononsenseapps.notepad.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    // Search/*w ww  .ja v  a 2  s.  c  o m*/
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        // list.onQueryTextChange(query);
        NotesListFragment list = getLeftFragment();
        if (list != null && list.mSearchView != null) {
            list.mSearchView.setQuery(query, false);
        } else if (list != null) {
            list.onQueryTextSubmit(query);
        }
        // Edit or View a list or a note.
    } else if (Intent.ACTION_EDIT.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction())) {
        handleEditIntent(intent);
    } else if (Intent.ACTION_INSERT.equals(intent.getAction())) {
        handleInsertIntent(intent);
    } else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        handleInsertIntent(intent);
    } else if (getString(R.string.complete_note_broadcast_intent).equals(intent.getAction())) {
        // Sent from lock-screen widget on 4.2 and above.
        // Send complete broadcast and finish
        long noteId = NotesEditorFragment.getIdFromUri(intent.getData());
        // This will complete the note
        if (noteId > -1) {
            Intent bintent = new Intent(this, NotePadBroadcastReceiver.class);
            bintent.setAction(getString(R.string.complete_note_broadcast_intent));
            bintent.putExtra(NotePad.Notes._ID, noteId);
            Log.d(TAG, "Sending complete broadcast");
            sendBroadcast(bintent);

            openNoteFragment(intent);

            // Toast.makeText(this, getString(R.string.completed),
            // Toast.LENGTH_SHORT).show();
        }
    } else {
        // Open a note
        if (noteIdToSelect > -1 && currentContent == CONTENTVIEW.DUAL) {
            Bundle arguments = new Bundle();
            arguments.putLong(NotesEditorFragment.KEYID, noteIdToSelect);
            NotesEditorFragment fragment = new NotesEditorFragment();
            fragment.setArguments(arguments);
            getFragmentManager().beginTransaction().replace(R.id.rightFragment, fragment).commit();
            noteIdToSelect = -1;
        }
    }
}

From source file:com.ht.app.RestaurantsActivity.java

private void handleIntent(Intent intent) {
    if (intent == null || intent.getAction() == null)
        return;/*w ww . ja  va 2  s  . c om*/

    if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
        doSearch(intent.getStringExtra(SearchManager.QUERY));
    } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {
        getPlace(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
    }
}

From source file:com.cyanogenmod.eleven.ui.activities.SearchActivity.java

/**
 * {@inheritDoc}//from  w  w w .  jav a2s . co  m
 */
@Override
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
    if (mAdapter.isSectionFooter(position)) {
        // since a footer should be after a list item by definition, let's look up the type
        // of the previous item
        SearchResult item = mAdapter.getTItem(position - 1);
        Intent intent = new Intent(this, SearchActivity.class);
        intent.putExtra(SearchManager.QUERY, mFilterString);
        intent.putExtra(SearchManager.SEARCH_MODE, item.mType.ordinal());
        startActivity(intent);
    } else {
        SearchResult item = mAdapter.getTItem(position);
        switch (item.mType) {
        case Artist:
            NavUtils.openArtistProfile(this, item.mArtist);
            break;
        case Album:
            NavUtils.openAlbumProfile(this, item.mAlbum, item.mArtist, item.mId);
            break;
        case Playlist:
            NavUtils.openPlaylist(this, item.mId, item.mTitle);
            break;
        case Song:
            // If it's a song, play it and leave
            final long[] list = new long[] { item.mId };
            MusicUtils.playAll(this, list, 0, -1, Config.IdType.NA, false);
            break;
        }
    }
}