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.deliciousdroid.activity.FragmentBaseActivity.java

@Override
@TargetApi(14)/*from  w  ww. j  a  va 2 s. co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = this;
    mAccountManager = AccountManager.get(this);
    settings = PreferenceManager.getDefaultSharedPreferences(this);

    loadSettings();
    init();

    if (android.os.Build.VERSION.SDK_INT >= 14) {
        getActionBar().setHomeButtonEnabled(true);
    }

    Intent intent = getIntent();

    if (Intent.ACTION_SEARCH.equals(intent.getAction()) && !intent.hasExtra("MainSearchResults")) {
        if (intent.hasExtra(SearchManager.QUERY)) {
            Intent i = new Intent(this, MainSearchResults.class);
            i.putExtras(intent.getExtras());
            startActivity(i);
            finish();
        } else {
            onSearchRequested();
        }
    } else if (Constants.ACTION_SEARCH_SUGGESTION.equals(intent.getAction())) {
        Uri data = intent.getData();
        String path = null;
        String tagname = null;

        if (data != null) {
            path = data.getPath();
            tagname = data.getQueryParameter("tagname");
        }

        if (data.getScheme() == null || !data.getScheme().equals("content")) {
            Intent i = new Intent(Intent.ACTION_VIEW, data);
            startActivity(i);
            finish();
        } else if (path.contains("bookmarks") && TextUtils.isDigitsOnly(data.getLastPathSegment())
                && intent.hasExtra(SearchManager.USER_QUERY)) {
            Intent viewBookmark = new Intent(this, ViewBookmark.class);
            viewBookmark.setAction(Intent.ACTION_VIEW);
            viewBookmark.setData(data);
            viewBookmark.removeExtra(SearchManager.USER_QUERY);
            Log.d("View Bookmark Uri", data.toString());
            startActivity(viewBookmark);
            finish();
        } else if (tagname != null) {
            Intent viewTags = new Intent(this, BrowseBookmarks.class);
            viewTags.setData(data);

            Log.d("View Tags Uri", data.toString());
            startActivity(viewTags);
            finish();
        }
    }
}

From source file:info.ipeanut.googletrainingcoursedemos.contactslist.ui.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();/*from w  w  w.j a v  a  2  s. 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_contactslist);

    // 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:fr.jbteam.jabboid.ui.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    /* if (BuildConfig.DEBUG) {
    Utils.enableStrictMode();//  w  w  w .j av  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.fragment_contacts);

    // 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.ifeel.mt.ui.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();// ww w  .  ja va  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);
    this.setTitle(R.string.activity_contacts_list_title);
    // 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:fr.eoidb.activity.MarketGroupListActivity.java

/** Called when the activity is first created. */
@Override//from  ww w  .ja v a 2 s  .com
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.market_group_list);

    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // handles a search query
        query = intent.getStringExtra(SearchManager.QUERY);
        showResults();
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        // handles a click on a search suggestion; launches activity to show word
        Intent itemIntent = new Intent(this, ItemInfoActivity.class);
        itemIntent.setData(intent.getData());
        startActivity(itemIntent);
        finish();
    } else {
        // If there is no data associated with the Intent, sets the data to the default URI, which
        // accesses a list of notes.
        if (intent.getData() == null) {
            intent.setData(MarketGroups.CONTENT_URI);
        }

        if (getIntent().getData().equals(MarketGroups.CONTENT_URI)) {
            marketGroupId = -1;
        } else {
            marketGroupId = ContentUris.parseId(getIntent().getData());
        }

        // Creates the backing adapter for the ListView.
        adapter = new SimpleCursorAdapter(this, R.layout.market_group_row, null, dataColumns, viewIDs,
                SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

        adapter.setViewBinder(new MarketGroupListViewBinder(false));

        ListView itemListView = (ListView) findViewById(R.id.market_group_list);
        itemListView.setOnItemClickListener(new MarketGroupOnItemListClickListener());
        // Sets the ListView's adapter to be the cursor adapter that was just created.
        itemListView.setAdapter(adapter);

        getSupportLoaderManager().initLoader(LOADER_ID, null, this);
    }
}

From source file:com.appsol.sharewithcontact.ui.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        // Utils.enableStrictMode();
    }/*from  ww w.j av a 2 s . com*/
    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_contact);

    // 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:net.potterpcs.recipebook.RecipeBookActivity.java

private void handleIntent(Intent intent) {
    // Fill in all the search/sort criteria
    if (intent.hasExtra(RecipeBook.SEARCH_EXTRA)) {
        searchQuery = intent.getStringExtra(RecipeBook.SEARCH_EXTRA);
    } else {//from   w ww .j  a v a2  s .  c o  m
        searchQuery = intent.getStringExtra(SearchManager.QUERY);
    }

    searchMode = (searchQuery != null);

    Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA);
    if (searchData == null) {
        sortDescending = intent.getBooleanExtra(SORT_DESCENDING, false);
        sortKey = intent.getIntExtra(SORT_KEY, 0);
        tagSearchMode = intent.hasExtra(RecipeBook.TAG_EXTRA);
        searchTag = intent.getStringExtra(RecipeBook.TAG_EXTRA);
        searchMin = intent.getIntExtra(RecipeBook.TIME_EXTRA_MIN, 0);
        searchMax = intent.getIntExtra(RecipeBook.TIME_EXTRA_MAX, 0);
        timeSearchMode = (searchMin != 0 || searchMax != 0);
    } else {
        sortDescending = searchData.getBoolean(SORT_DESCENDING, false);
        sortKey = searchData.getInt(SORT_KEY, 0);
        tagSearchMode = searchData.containsKey(RecipeBook.TAG_EXTRA);
        searchTag = searchData.getString(RecipeBook.TAG_EXTRA);
        searchMin = searchData.getInt(RecipeBook.TIME_EXTRA_MIN, 0);
        searchMax = searchData.getInt(RecipeBook.TIME_EXTRA_MAX, 0);
        timeSearchMode = (searchMin != 0 || searchMax != 0);
    }

    // In case the max value is left blank
    if (searchMax == 0 && searchMin > 0) {
        searchMax = Integer.MAX_VALUE;
    }

    //      Log.i(TAG, "Sort descending == " + sortDescending + ", sort key == " + sortKey 
    //            + " max time == " + searchMax + " min time == " + searchMin);

    // Android 3.0+ has the action bar, and requires this call to change menu items.
    // Earlier versions don't have it, because they don't need it.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        invalidateOptionsMenu();
    }
}

From source file:fr.eoit.activity.ItemListActivity.java

/** Called when the activity is first created. */
@Override/*  w w  w . j a  v a  2  s.  com*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.itemlist);

    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // handles a search query
        query = intent.getStringExtra(SearchManager.QUERY);
        showResults();
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        // handles a click on a search suggestion; launches activity to show word
        Intent itemIntent = new Intent(this, ItemInfo2Activity.class);
        itemIntent.setData(intent.getData());
        startActivity(itemIntent);
        finish();
    } else {
        // If there is no data associated with the Intent, sets the data to the default URI, which
        // accesses a list of notes.
        if (intent.getData() == null) {
            intent.setData(Item.CONTENT_URI);
        }

        // Creates the backing adapter for the ListView.
        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));
        // Sets the ListView's adapter to be the cursor adapter that was just created.
        itemListView.setAdapter(adapter);

        getSupportLoaderManager().initLoader(FAVORITE_LOADER_ID, null, this);
    }

    MissingAPITips dialog = new MissingAPITips(this);
    if (dialog.isActive(this) && Parameters.characterId == -1 && Parameters.keyId == -1) {
        dialog.show(getSupportFragmentManager(), "missing_api_dialog");
    }
}

From source file:com.infine.android.devoxx.ui.SearchActivity.java

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);/*from  w w w.ja v  a 2s .co  m*/
    mQuery = intent.getStringExtra(SearchManager.QUERY);

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

    mTabHost.setCurrentTab(0);

    mSessionsFragment.reloadFromArguments(getSessionsFragmentArguments());
    mSpeakersFragment.reloadFromArguments(getSpeakersFragmentArguments());
}

From source file:edu.umbc.cs.ebiquity.mithril.parserapp.contentparsers.contacts.ContactsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();/*from   w  w  w .  j ava2  s.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_contact_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);
    }
}