Example usage for android.content Intent ACTION_WEB_SEARCH

List of usage examples for android.content Intent ACTION_WEB_SEARCH

Introduction

In this page you can find the example usage for android.content Intent ACTION_WEB_SEARCH.

Prototype

String ACTION_WEB_SEARCH

To view the source code for android.content Intent ACTION_WEB_SEARCH.

Click Source Link

Document

Activity Action: Perform a web search.

Usage

From source file:com.akop.bach.fragment.playstation.TrophiesFragment.java

@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();

    if (mGameTitle != null && info.targetView.getTag() instanceof ViewHolder) {
        ViewHolder vh = (ViewHolder) info.targetView.getTag();

        switch (menuItem.getItemId()) {
        case R.id.menu_google_trophies:
            Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
            searchIntent.putExtra(SearchManager.QUERY,
                    getString(R.string.google_trophy_f, mGameTitle, vh.title.getText()));

            startActivity(searchIntent);
            return true;
        }//w  w  w .  j av  a2 s  .com
    }

    return super.onContextItemSelected(menuItem);
}

From source file:com.akop.bach.fragment.xboxlive.GamesFragment.java

@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();

    if (info.targetView.getTag() instanceof ViewHolder) {
        ViewHolder vh = (ViewHolder) info.targetView.getTag();

        switch (menuItem.getItemId()) {
        case R.id.menu_game_overview:

            GameOverview.actionShow(getActivity(), mAccount, vh.gameUrl);
            return true;

        case R.id.google_achievements:

            Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
            searchIntent.putExtra(SearchManager.QUERY,
                    getString(R.string.google_achievements_f, vh.title.getText()));
            startActivity(searchIntent);

            return true;

        case R.id.menu_visit_webpage:

            Intent wwwIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(vh.gameUrl));
            startActivity(wwwIntent);/*w  w  w  .ja v a  2  s  . c  o m*/

            return true;
        }
    }

    return super.onContextItemSelected(menuItem);
}

From source file:com.akop.bach.fragment.xboxlive.AchievementsFragment.java

@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();

    if (mGameTitle != null && info.targetView.getTag() instanceof ViewHolder) {
        ViewHolder vh = (ViewHolder) info.targetView.getTag();

        switch (menuItem.getItemId()) {
        case R.id.google_achievement:
            Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
            searchIntent.putExtra(SearchManager.QUERY,
                    getString(R.string.google_achievement_f, mGameTitle, vh.title.getText()));
            startActivity(searchIntent);
            return true;
        }/*from  ww  w .j  a  va 2 s.  c  o m*/
    }

    return super.onContextItemSelected(menuItem);
}

From source file:com.example.android.navigationdrawerexample.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;
    }//from  w w  w. ja v  a 2 s. c  om
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_websearch:
        // create intent to perform web search for this planet
        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 {
            makeText(this, R.string.app_not_available, LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.example.volunteerhandbook.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (noDrawYet)
        return true;
    // 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  ww  .ja  v  a  2s.  c o m*/
    // Handle action buttons
    closeSpeaker();
    ListRecordBase record = (ListRecordBase) mCurrentFragment;
    int itemId = item.getItemId();
    switch (itemId) {
    case R.id.action_new:
    case R.id.action_modify:
    case R.id.action_delete:
    case R.id.action_check:
    case R.id.action_save:
        record.getArguments().putInt(ListRecordBase.ACTION_TYPE, itemId);
        FragmentManager fragmentManager = getFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.main_content_frame, mCurrentFragment).commit();
        break;
    case R.id.action_join:
        break;
    case R.id.action_websearch:
        // create intent to perform web search for this planet
        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();
    default:
        super.onOptionsItemSelected(item);
    }
    return true;
}

From source file:com.tt.jobtracker.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;
    }/*from   w  w w. ja va2s .co m*/
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_logout:
        // create intent to perform web search for this planet
        Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, getSupportActionBar().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_name, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

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  .  j a  v  a 2s  .c o 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.andrew.apollo.ui.activities.ProfileActivity.java

/**
 * Searches Google for the artist or album
 *///from  w w  w.  j  a v  a 2  s . co  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   www .  j  a va  2 s  .com
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 webSearch(String query) {
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra("query", query);
    launchIntent(intent);
}