Example usage for android.content Intent ACTION_SEARCH

List of usage examples for android.content Intent ACTION_SEARCH

Introduction

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

Prototype

String ACTION_SEARCH

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

Click Source Link

Document

Activity Action: Perform a search.

Usage

From source file:org.peterbaldwin.vlcremote.app.PlaybackActivity.java

@Override
protected void onNewIntent(Intent intent) {
    String host = intent.getStringExtra(Intents.EXTRA_REMOTE_HOST);
    if (host != null) {
        int port = intent.getIntExtra(Intents.EXTRA_REMOTE_PORT, 8080);
        String authority = host + ":" + port;
        changeServer(authority);/* w  w  w. j  a  v  a 2 s . c o  m*/
    }

    String action = intent.getAction();
    if (Intent.ACTION_VIEW.equals(action) || Intents.ACTION_REMOTE_VIEW.equals(action)
            || Intents.ACTION_VIEW.equals(action)) {
        Uri data = intent.getData();
        if (data != null) {
            changeInput(data.toString());
        }
    } else if (Intent.ACTION_SEARCH.equals(action)) {
        String input = intent.getStringExtra(SearchManager.QUERY);
        changeInput(input);
    }
}

From source file:org.geometerplus.android.fbreader.FBReader.java

@Override
protected void onNewIntent(final Intent intent) {
    final String action = intent.getAction();
    final Uri data = intent.getData();

    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
        super.onNewIntent(intent);
    } else if (Intent.ACTION_VIEW.equals(action) && data != null
            && "fbreader-action".equals(data.getScheme())) {
        myFBReaderApp.runAction(data.getEncodedSchemeSpecificPart(), data.getFragment());
    } else if (Intent.ACTION_VIEW.equals(action) || FBReaderIntents.Action.VIEW.equals(action)) {
        myOpenBookIntent = intent;//from   w  ww . j a va2 s  . c o  m
        if (myFBReaderApp.Model == null && myFBReaderApp.ExternalBook != null) {
            final ExternalFormatPlugin plugin = (ExternalFormatPlugin) myFBReaderApp.ExternalBook
                    .getPluginOrNull();
            try {
                startActivity(PluginUtil.createIntent(plugin, PluginUtil.ACTION_KILL));
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
            }
        }
    } else if (FBReaderIntents.Action.PLUGIN.equals(action)) {
        new RunPluginAction(this, myFBReaderApp, data).run();
    } else if (Intent.ACTION_SEARCH.equals(action)) {
        final String pattern = intent.getStringExtra(SearchManager.QUERY);
        final Runnable runnable = new Runnable() {
            public void run() {
                final TextSearchPopup popup = (TextSearchPopup) myFBReaderApp.getPopupById(TextSearchPopup.ID);
                popup.initPosition();
                myFBReaderApp.MiscOptions.TextSearchPattern.setValue(pattern);
                if (myFBReaderApp.getTextView().search(pattern, true, false, false, false) != 0) {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            myFBReaderApp.showPopup(popup.getId());
                        }
                    });
                } else {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            UIUtil.showErrorMessage(FBReader.this, "textNotFound");
                            popup.StartPosition = null;
                        }
                    });
                }
            }
        };
        UIUtil.wait("search", runnable, this);
    } else if (FBReaderIntents.Action.CLOSE.equals(intent.getAction())) {
        myCancelIntent = intent;
        myOpenBookIntent = null;
    } else if (FBReaderIntents.Action.PLUGIN_CRASH.equals(intent.getAction())) {
        final Book book = FBReaderIntents.getBookExtra(intent);
        myFBReaderApp.ExternalBook = null;
        myOpenBookIntent = null;
        getCollection().bindToService(this, new Runnable() {
            public void run() {
                Book b = myFBReaderApp.Collection.getRecentBook(0);
                if (b.equals(book)) {
                    b = myFBReaderApp.Collection.getRecentBook(1);
                }
                myFBReaderApp.openBook(b, null, null, FBReader.this);
            }
        });
    } else {
        super.onNewIntent(intent);
    }
}

From source file:com.contralabs.inmap.activities.MainActivity.java

private boolean verifyIntentSearch(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        EasyTracker.getTracker().sendEvent("UserAction", "Search", query, 0l);
        if (query.length() > 2 && query.endsWith("s")) // To search plurals as singular (pt)
            query = query.substring(0, query.length() - 1);
        mStoreListFragment.setStoreParameters(new StoreParameters().setText(query));
        if (!isLeftMenuShowing())
            toggleList();/*  w  w w . ja  v  a  2  s  . com*/
        if (!isShowingStoreList)
            showStoreList();
        mDbAdapter.open();
        try {
            mDbAdapter.saveSearchPerformed(null, query); // FIXME Get facebook id if logged in
        } finally {
            mDbAdapter.close();
        }
        return true;
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        // Handle a suggestions click (because the suggestions all use ACTION_VIEW)
        long id = Long.parseLong(intent.getDataString());
        Store store;
        mDbAdapter.open();
        try {
            store = mDbAdapter.getStore(id);
        } finally {
            mDbAdapter.close();
        }
        onStoreSelected(store);
        return true;
    } else if (intent.getBooleanExtra(SHOW_SEARCH, false)) {
        onSearchClicked();
        return true;
    }
    return false;
}

From source file:com.vuze.android.remote.AndroidUtils.java

public static boolean executeSearch(String search, Context context, SessionInfo sessionInfo) {
    Intent myIntent = new Intent(Intent.ACTION_SEARCH);
    myIntent.setClass(context, MetaSearch.class);
    RemoteProfile remoteProfile = sessionInfo.getRemoteProfile();
    if (remoteProfile != null && remoteProfile.getRemoteType() == RemoteProfile.TYPE_LOOKUP) {
        Bundle bundle = new Bundle();
        bundle.putString("com.vuze.android.remote.searchsource", sessionInfo.getRpcRoot());
        if (remoteProfile.getRemoteType() == RemoteProfile.TYPE_LOOKUP) {
            bundle.putString("com.vuze.android.remote.ac", remoteProfile.getAC());
        }/*from  www  .j ava  2  s . c  om*/
        bundle.putString(SessionInfoManager.BUNDLE_KEY, remoteProfile.getID());

        myIntent.putExtra(SearchManager.APP_DATA, bundle);
    }

    myIntent.putExtra(SearchManager.QUERY, search);

    context.startActivity(myIntent);
    return true;
}

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

private void displayIntent(Intent intent) {
    final String queryAction = intent.getAction();
    final String orderby = Tracks.CREATION_TIME + " DESC";
    Cursor tracksCursor = null;/*from  ww w  . java2  s . c  om*/
    if (Intent.ACTION_SEARCH.equals(queryAction)) {
        // Got to SEARCH a query for tracks, make a list
        tracksCursor = doSearchWithIntent(intent);
    } else if (Intent.ACTION_VIEW.equals(queryAction)) {
        final Uri uri = intent.getData();
        if ("content".equals(uri.getScheme()) && GPStracking.AUTHORITY.equals(uri.getAuthority())) {
            // Got to VIEW a single track, instead hand it of to the LoggerMap
            Intent notificationIntent = new Intent(this, LoggerMap.class);
            notificationIntent.setData(uri);
            startActivity(notificationIntent);
            finish();
        } else if (uri.getScheme().equals("file") || uri.getScheme().equals("content")) {

            mImportTrackName = uri.getLastPathSegment();
            // Got to VIEW a GPX filename
            mImportAction = new Runnable() {
                @Override
                public void run() {
                    new GpxParser(TrackList.this, TrackList.this).execute(uri);
                }
            };
            showDialog(DIALOG_IMPORT);
            tracksCursor = managedQuery(Tracks.CONTENT_URI,
                    new String[] { Tracks._ID, Tracks.NAME, Tracks.CREATION_TIME }, null, null, orderby);
        } else {
            Log.e(this, "Unable to VIEW " + uri);
        }
    } else {
        // Got to nothing, make a list of everything
        tracksCursor = managedQuery(Tracks.CONTENT_URI,
                new String[] { Tracks._ID, Tracks.NAME, Tracks.CREATION_TIME }, null, null, orderby);
    }
    displayCursor(tracksCursor);

}

From source file:gc.david.dfm.ui.activity.MainActivity.java

private void handleIntents(final Intent intent) {
    if (intent != null) {
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            handleSearchIntent(intent);//from   w  w  w.j a v a2s.  co  m
        } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
            handleViewPositionIntent(intent);
        }
    }
}

From source file:fr.cph.chicago.activity.MainActivity.java

@Override
public void startActivity(Intent intent) {
    // check if search intent
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        ArrayList<BikeStation> bikeStations = getIntent().getExtras().getParcelableArrayList("bikeStations");
        intent.putParcelableArrayListExtra("bikeStations", bikeStations);
    }/*from w w w .  j a va2s  . com*/
    super.startActivity(intent);
}

From source file:com.android.mail.ui.TwoPaneController.java

@Override
public boolean shouldShowFirstConversation() {
    return Intent.ACTION_SEARCH.equals(mActivity.getIntent().getAction()) && shouldEnterSearchConvMode();
}

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

private void handleIntent(Intent intent) {
    //  ? ? //  w w w  . java2  s  .  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: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);//from  ww  w.j  a  va 2  s. com
    } 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();
    }
}