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:net.networksaremadeofstring.cyllell.Search.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_main);

    //Fancy title
    ((TextView) findViewById(R.id.TitleBarText))
            .setTypeface(Typeface.createFromAsset(this.getAssets(), "fonts/codeops_serif.ttf"));

    //List view to hold search results
    list = (ListView) findViewById(R.id.SearchResultsListView);

    //Prep the handler to do all the UI updating etc
    MakeHandler();/* w  ww.j av  a 2 s  .com*/

    //This is for the crafted search (not visible if the user came in via a search intent
    ((Button) findViewById(R.id.SearchButton)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            index = ((Spinner) findViewById(R.id.IndexChoice)).getSelectedItem().toString().toLowerCase();
            query = ((TextView) findViewById(R.id.SearchStringEditText)).getText().toString();
            PerformSearch(true);
        }
    });

    // Get the intent, verify the action and get the query
    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        findViewById(R.id.SearchParamContainer).setVisibility(8);
        //findViewById(R.id.ShowSearchParams).setVisibility(0);
        findViewById(R.id.SearchMainRelativeLayout).invalidate();

        query = intent.getStringExtra(SearchManager.QUERY);
        index = "node";

        PerformSearch(false);
    } else if (Intent.ACTION_SEARCH_LONG_PRESS.equals(intent.getAction())) {
        //findViewById(R.id.SearchParamContainer).setVisibility(0);
        //findViewById(R.id.ShowSearchParams).setVisibility(4);
    } else {
        //findViewById(R.id.SearchParamContainer).setVisibility(0);
        //findViewById(R.id.ShowSearchParams).setVisibility(4);
    }

    /*((ImageView)findViewById(R.id.ShowSearchParams)).setOnClickListener(new View.OnClickListener() {
    public void onClick(View v)
    {
       findViewById(R.id.SearchParamContainer).setVisibility(0);
      findViewById(R.id.ShowSearchParams).setVisibility(4);
      findViewById(R.id.SearchMainRelativeLayout).invalidate();
    }
     });
            
    ((ImageView)findViewById(R.id.HideSearchParams)).setOnClickListener(new View.OnClickListener() {
    public void onClick(View v)
    {
       findViewById(R.id.SearchParamContainer).setVisibility(8);
      findViewById(R.id.ShowSearchParams).setVisibility(0);
      findViewById(R.id.SearchMainRelativeLayout).invalidate();
              
    }
     });*/
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SearchActivity.java

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);//from  w  w w. j a v a 2  s  . c  o  m
    String query = intent.getStringExtra(SearchManager.QUERY);

    setTitle(Html.fromHtml(getString(R.string.title_search_query, query)));

    mSessionsFragment.reloadFromArguments(
            intentToFragmentArguments(new Intent(Intent.ACTION_VIEW, Sessions.buildSearchUri(query))));

    EasyTracker.getTracker().sendView("Search: " + query);
    LOGD("Tracker", "Search: " + query);

    updateDetailBackground();
}

From source file:com.evilgenius.testproject.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();/*from   w ww .j  av a2s . c  om*/
    }
    super.onCreate(savedInstanceState);
    InitActionbar();
    // Set main content view. On smaller screen devices this is a single pane view with one
    // fragment. One larger screen devices this is a two pane view with two fragments.
    setContentView(R.layout.activity_memo_book);

    // Check if two pane bool is set based on resource directories
    isTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes);

    // Check if this activity instance has been triggered as a result of a search query. This
    // will only happen on pre-HC OS versions as from HC onward search is carried out using
    // an ActionBar SearchView which carries out the search in-line without loading a new
    // Activity.
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {

        // Fetch query from intent and notify the fragment that it should display search
        // results instead of all contacts.
        String searchQuery = getIntent().getStringExtra(SearchManager.QUERY);
        ContactsListFragment mContactsListFragment = (ContactsListFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contact_list);

        // This flag notes that the Activity is doing a search, and so the result will be
        // search results rather than all contacts. This prevents the Activity and Fragment
        // from trying to a search on search results.
        isSearchResultView = true;
        mContactsListFragment.setSearchQuery(searchQuery);

        // Set special title for search results
        String title = getString(R.string.contacts_list_search_results_title, searchQuery);
        setTitle(title);
    }

    if (isTwoPaneLayout) {
        // If two pane layout, locate the contact detail fragment
        //            mContactDetailFragment = (ContactDetailFragment)
        //                    getSupportFragmentManager().findFragmentById(R.id.contact_detail);
    }
}

From source file:com.dsdar.thosearoundme.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    if (BuildConfig.DEBUG) {
        // Utils.enableStrictMode();
    }//from   ww  w  .  j  ava  2s . c o m
    super.onCreate(savedInstanceState);
    itsTeamNameEt = (EditText) findViewById(R.id.etTeamName);
    // Set main content view. On smaller screen devices this is a single
    // pane view with one
    // fragment. One larger screen devices this is a two pane view with two
    // fragments.
    setContentView(R.layout.activity_main);

    // Check if two pane bool is set based on resource directories
    // isTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes);

    // Check if this activity instance has been triggered as a result of a
    // search query. This
    // will only happen on pre-HC OS versions as from HC onward search is
    // carried out using
    // an ActionBar SearchView which carries out the search in-line without
    // loading a new
    // Activity.
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
        ContactsListFragment aContactsListFragment;

        // Fetch query from intent and notify the fragment that it should
        // display search
        // results instead of all contacts.
        String searchQuery = getIntent().getStringExtra(SearchManager.QUERY);
        Log.d("niaz", "searchQuery:::" + searchQuery);
        aContactsListFragment = (ContactsListFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contact_list);

        // This flag notes that the Activity is doing a search, and so the
        // result will be
        // search results rather than all contacts. This prevents the
        // Activity and Fragment
        // from trying to a search on search results.
        isSearchResultView = true;

        // Set special title for search results
        String title = getString(R.string.contacts_list_search_results_title, searchQuery);
        Log.d(TAG, "niaz:::searchQuery=" + searchQuery + ",title=" + title);
        setTitle(title);

    }
    // Niaz parentActivity = AddTeam Member
    String parentActivity = getIntent().getSerializableExtra("parentActivity").toString();
    processName = parentActivity;
    if (parentActivity.equals("Add Team Member")) {
        System.out.println("============ Entered the if condition ===========");
        itsTeamNameEt = (EditText) findViewById(R.id.etTeamName);
        // niaz home
        itsTeamNameEt.setText(getIntent().getSerializableExtra("teamName").toString());
        itsTeamNameEt.setKeyListener(null);

    }

    // if (isTwoPaneLayout) {
    // // If two pane layout, locate the contact detail fragment
    // mContactDetailFragment = (ContactDetailFragment)
    // getSupportFragmentManager().findFragmentById(R.id.contact_detail);
    // }
}

From source file:com.google.android.demos.jamendo.app.SearchActivity.java

/** {@inheritDoc} */
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Intent intent = getIntent();//w  w  w.  ja  va  2 s.c  o  m
    String query = intent.getStringExtra(SearchManager.QUERY);

    Uri.Builder builder = JamendoContract.AUTHORITY_URI.buildUpon();
    builder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
    builder.appendPath(query);
    Uri uri = builder.build();
    String[] projection = { BaseColumns._ID, SearchManager.SUGGEST_COLUMN_ICON_2,
            SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_TEXT_2 };
    String selection = JamendoContract.PARAM_IMAGE_SIZE + "=" + mImageSize;
    String[] selectionArgs = null;
    String sortOrder = null;
    return new CursorLoader(this, uri, projection, selection, selectionArgs, sortOrder);
}

From source file:com.example.contactslist.ui.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();//w  w  w. j a v  a  2s . c  o  m
    }
    super.onCreate(savedInstanceState);

    // Set main content view. On smaller screen devices this is a single pane view with one
    // fragment. One larger screen devices this is a two pane view with two fragments.
    setContentView(R.layout.activity_main);

    // Check if two pane bool is set based on resource directories
    isTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes);

    // Check if this activity instance has been triggered as a result of a search query. This
    // will only happen on pre-HC OS versions as from HC onward search is carried out using
    // an ActionBar SearchView which carries out the search in-line without loading a new
    // Activity.
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {

        // Fetch query from intent and notify the fragment that it should display search
        // results instead of all contacts.
        String searchQuery = getIntent().getStringExtra(SearchManager.QUERY);

        ContactsListFragment mContactsListFragment = (ContactsListFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contact_list);
        // This flag notes that the Activity is doing a search, and so the result will be
        // search results rather than all contacts. This prevents the Activity and Fragment
        // from trying to a search on search results.
        isSearchResultView = true;
        mContactsListFragment.setSearchQuery(searchQuery);

        // Set special title for search results
        String title = getString(R.string.contacts_list_search_results_title, searchQuery);
        setTitle(title);
    }

    if (isTwoPaneLayout) {
        // If two pane layout, locate the contact detail fragment
        mContactDetailFragment = (ContactDetailFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contact_detail);
    }
}

From source file:com.google.android.apps.iosched2.ui.SearchActivity.java

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);//w w w  .  ja  va 2s . c o  m
    mQuery = intent.getStringExtra(SearchManager.QUERY);

    doEasterEgg(mQuery);

    final CharSequence title = getString(R.string.title_search_query, mQuery);
    getActivityHelper().setActionBarTitle(title);

    mTabHost.setCurrentTab(0);

    mSessionsFragment.reloadFromArguments(getSessionsFragmentArguments());

    if (Setup.FEATURE_VENDORS_ON) {
        mVendorsFragment.reloadFromArguments(getVendorsFragmentArguments());
    }
}

From source file:com.fastbootmobile.encore.app.SearchActivity.java

private void handleIntent(final Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        if (!intent.hasExtra(SearchManager.QUERY)) {
            Toast.makeText(this, "Invalid search query: missing query", Toast.LENGTH_SHORT).show();
        } else {//w  w  w.j av  a2  s. c  o m
            final String query = intent.getStringExtra(SearchManager.QUERY).trim();
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mActiveFragment.resetResults();
                    mActiveFragment.setArguments(query);
                    ProviderAggregator.getDefault().startSearch(query);
                }
            }, 200);

            SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                    SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
            suggestions.saveRecentQuery(query, null);
        }
    }
}

From source file:com.dsdar.thosearoundme.TeamMemberAddActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    if (BuildConfig.DEBUG) {
        // Utils.enableStrictMode();
    }/* w  w  w. ja  va 2 s.c  o  m*/
    super.onCreate(savedInstanceState);
    itsTeamNameEt = (TextView) findViewById(R.id.tvAddMemberTeamName);
    // Set main content view. On smaller screen devices this is a single
    // pane view with one
    // fragment. One larger screen devices this is a two pane view with two
    // fragments. 
    setContentView(R.layout.tm_add_activity_main);

    // Check if two pane bool is set based on resource directories
    // isTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes);

    // Check if this activity instance has been triggered as a result of a
    // search query. This
    // will only happen on pre-HC OS versions as from HC onward search is
    // carried out using
    // an ActionBar SearchView which carries out the search in-line without
    // loading a new
    // Activity.
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
        MemberAddContactsListFragment aContactsListFragment;

        // Fetch query from intent and notify the fragment that it should
        // display search
        // results instead of all contacts.
        String searchQuery = getIntent().getStringExtra(SearchManager.QUERY);
        Log.d("niaz", "searchQuery:::" + searchQuery);
        aContactsListFragment = (MemberAddContactsListFragment) getSupportFragmentManager()
                .findFragmentById(R.id.tm_add_contact_list);

        // This flag notes that the Activity is doing a search, and so the
        // result will be
        // search results rather than all contacts. This prevents the
        // Activity and Fragment
        // from trying to a search on search results.
        isSearchResultView = true;

        // Set special title for search results
        String title = getString(R.string.contacts_list_search_results_title, searchQuery);
        Log.d(TAG, "niaz:::searchQuery=" + searchQuery + ",title=" + title);
        setTitle(title);

    }
    // Niaz parentActivity = AddTeam Member
    String parentActivity = getIntent().getExtras().getString("teamActivity");
    processName = parentActivity;
    System.out.println("============ Entered the if condition ===========");
    itsTeamNameEt = (TextView) findViewById(R.id.tvAddMemberTeamName);
    // niaz home
    itsTeamNameEt.setText("Add to [" + getIntent().getSerializableExtra("teamName").toString() + "] Group ");

    final EditText aTeamNameEt = (EditText) findViewById(R.id.etTeamName);
    aTeamNameEt.setText(getIntent().getSerializableExtra("teamName").toString());

    // itsTeamNameEt.setKeyListener(null);

    // if (isTwoPaneLayout) {
    // // If two pane layout, locate the contact detail fragment
    // mContactDetailFragment = (ContactDetailFragment)
    // getSupportFragmentManager().findFragmentById(R.id.contact_detail);
    // }
}

From source file:org.medankulinar.MixListView.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        doMixSearch(query);//from   w w  w  .  j a  v a 2 s .c om
    }
}