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:edu.cmu.ece.ece551.uis.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // 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);//  ww w .j  a va  2 s  .c  om
        } else {
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.samsunghack.apps.android.noq.NavDrawerMainActivity.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 . j  ava  2 s .c o  m
    // 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 {
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;

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

From source file:com.example.android.navigationdrawerexample.activities.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 (drawerToggle.onOptionsItemSelected(item)) {
        return true;
    }//from   w  ww .  ja  v a  2s  .c  o  m
    // 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 {
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.desitum.landscape_connect.activities.HomeActivity.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  ww. j  a  va2s.  c om*/
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_settings:
        // 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, "not available", Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.jazz.MyActivity.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;
    }//  ww w  .j  av a2s  .c o m
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_search:
        // 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();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:br.com.dsasoft.example.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;
    }/*  ww  w.j  a  v  a2  s.co m*/
    // 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, 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_not_available, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:cn.androidy.swiftlib.navigationdrawer.NavigationDrawerActivity.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  va 2 s  .c o m*/
    // 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 {
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:piuk.blockchain.android.ui.SendCoinsActivity.java

private void handleIntent(final Intent intent) {
    final String action = intent.getAction();
    final Uri intentUri = intent.getData();
    final String scheme = intentUri != null ? intentUri.getScheme() : null;

    final String address;
    final BigInteger amount;

    if ((Intent.ACTION_VIEW.equals(action)) && intentUri != null && "bitcoin".equals(scheme)) {
        try {/*  w w w. j  a  va  2 s  . c  om*/
            final BitcoinURI bitcoinUri = new BitcoinURI(intentUri.toString());
            address = bitcoinUri.getAddress().toString();
            amount = bitcoinUri.getAmount();
        } catch (final BitcoinURIParseException x) {
            errorDialog(R.string.send_coins_uri_parse_error_title, intentUri.toString());
            return;
        }
    } else if (Intent.ACTION_WEB_SEARCH.equals(action) && intent.hasExtra(INTENT_EXTRA_QUERY)) {
        try {
            final BitcoinURI bitcoinUri = new BitcoinURI(intent.getStringExtra(INTENT_EXTRA_QUERY));
            if (bitcoinUri.getAddress() == null) {
                address = null;
                amount = null;
            } else {
                address = bitcoinUri.getAddress().toString();
                amount = bitcoinUri.getAmount();
            }
        } catch (final BitcoinURIParseException x) {
            errorDialog(R.string.send_coins_uri_parse_error_title, intentUri.toString());
            return;
        }
    } else if (intent.hasExtra(INTENT_EXTRA_ADDRESS)) {
        address = intent.getStringExtra(INTENT_EXTRA_ADDRESS);
        amount = null;
    } else {
        return;
    }

    if (address != null || amount != null)
        updateSendCoinsFragment(address, amount);
    else
        longToast(R.string.send_coins_parse_address_error_msg);
}

From source file:com.kawakawaplanning.rssreader.Main.MainActivity.java

public void browser(View v) {
    Vibrator vib = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    vib.vibrate(50);/*from  w  w  w.  jav a 2 s.  com*/
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, "RSS ????");
    startActivity(intent);
}

From source file:com.example.tobias.androidtestapp.navigationdrawer.NavigationDrawerMain.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 2s . co  m
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_websearch:
        // Im Web nach dem Planeten suchen der aktuell angezeigt wird
        Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, getSupportActionBar().getTitle());
        // falls Webbrowser installiert, diesen mit unserem Suchbegriff starten
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        } else {
            // falls kein Webbrowser installiert, Toast machen
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}