Example usage for android.net Uri getQueryParameter

List of usage examples for android.net Uri getQueryParameter

Introduction

In this page you can find the example usage for android.net Uri getQueryParameter.

Prototype

@Nullable
public String getQueryParameter(String key) 

Source Link

Document

Searches the query string for the first value with the given key.

Usage

From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java

private void popupRegisterFirst(Uri uri) {
    String invitorName = uri.getQueryParameter("u");
    if (invitorName != null)
        invitorName = invitorName.replaceAll("\\+", " ");

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(getString(R.string.friend_invitation_register_first, invitorName));
    builder.setPositiveButton(R.string.rogerthat, null);
    builder.create().show();//from   ww w  . j  a v a2  s  . c o  m
}

From source file:org.xbmc.kore.ui.sections.remote.RemoteActivity.java

/**
 * Converts a video url to a Kodi plugin URL.
 *
 * @param playuri some URL/*from  w ww. j a va  2 s.  c  o  m*/
 * @return plugin URL
 */
private String toPluginUrl(Uri playuri) {
    String host = playuri.getHost();
    if (host.endsWith("svtplay.se")) {
        Pattern pattern = Pattern.compile("^(?:https?:\\/\\/)?(?:www\\.)?svtplay\\.se\\/video\\/(\\d+\\/.*)",
                Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(playuri.toString());
        if (matcher.matches()) {
            return "plugin://plugin.video.svtplay/?url=%2Fvideo%2F" + URLEncoder.encode(matcher.group(1))
                    + "&mode=video";
        }
    } else if (host.endsWith("vimeo.com")) {
        String last = playuri.getLastPathSegment();
        if (last.matches("\\d+")) {
            return "plugin://plugin.video.vimeo/play/?video_id=" + last;
        }
    } else if (host.endsWith("youtube.com")) {
        if (playuri.getPathSegments().contains("playlist")) {
            return "plugin://plugin.video.youtube/play/?order=default&playlist_id="
                    + playuri.getQueryParameter("list");
        } else {
            return "plugin://plugin.video.youtube/play/?video_id=" + playuri.getQueryParameter("v");
        }
    } else if (host.endsWith("youtu.be")) {
        return "plugin://plugin.video.youtube/play/?video_id=" + playuri.getLastPathSegment();
    }
    return null;
}

From source file:id.ridon.keude.AppDetailsData.java

/**
 * Attempt to extract the appId from the intent which launched this activity.
 * Various different intents could cause us to show this activity, such as:
 * <ul>//from w ww  .j  av  a 2s . co m
 *     <li>market://details?id=[app_id]</li>
 *     <li>https://f-droid.org/app/[app_id]</li>
 *     <li>fdroid.app:[app_id]</li>
 * </ul>
 * @return May return null, if we couldn't find the appId. In this case, you will
 * probably want to do something drastic like finish the activity and show some
 * feedback to the user (this method will <em>not</em> do that, it will just return
 * null).
 */
private String getAppIdFromIntent() {
    Intent i = getIntent();
    Uri data = i.getData();
    String appId = null;
    if (data != null) {
        if (data.isHierarchical()) {
            if (data.getHost() != null && data.getHost().equals("details")) {
                // market://details?id=app.id
                appId = data.getQueryParameter("id");
            } else {
                // https://f-droid.org/app/app.id
                appId = data.getLastPathSegment();
                if (appId != null && appId.equals("app")) {
                    appId = null;
                }
            }
        } else {
            // fdroid.app:app.id
            appId = data.getEncodedSchemeSpecificPart();
        }
        Log.d(TAG, "AppDetails launched from link, for '" + appId + "'");
    } else if (!i.hasExtra(EXTRA_APPID)) {
        Log.e(TAG, "No application ID in AppDetails!?");
    } else {
        appId = i.getStringExtra(EXTRA_APPID);
    }
    return appId;
}

From source file:com.hybris.mobile.lib.commerce.provider.CatalogProvider.java

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SQLiteDatabase sqLiteDatabase = mDatabaseHelper.getWritableDatabase();
    String tableName;//from w  w  w . ja va2  s .  c o  m
    String where;
    String order = "";
    Bundle bundleSyncAdapter = new Bundle();
    String lastPathSegment = uri.getLastPathSegment();

    if (StringUtils.isNotBlank(sortOrder)) {
        order = " ORDER BY " + sortOrder;
    }

    switch (URI_MATCHER.match(uri)) {

    // Getting the content for a group (list of simple data)
    case CatalogContract.Provider.CODE_GROUP_ID:
        tableName = CatalogContract.DataBaseDataSimple.TABLE_NAME;
        where = CatalogContract.DataBaseDataLinkGroup.TABLE_NAME + "."
                + CatalogContract.DataBaseDataLinkGroup.ATT_GROUP_ID + "='" + lastPathSegment + "'";

        // Limit for the query on the sync adapter
        String currentPage = uri.getQueryParameter(CatalogContract.Provider.QUERY_PARAM_CURRENT_PAGE);
        String pageSize = uri.getQueryParameter(CatalogContract.Provider.QUERY_PARAM_PAGE_SIZE);

        // Bundle information for the syncing part
        bundleSyncAdapter.putString(CatalogSyncConstants.SYNC_PARAM_GROUP_ID, lastPathSegment);

        if (StringUtils.isNotBlank(currentPage) && StringUtils.isNotBlank(pageSize)) {
            bundleSyncAdapter.putInt(CatalogSyncConstants.SYNC_PARAM_CURRENT_PAGE,
                    Integer.valueOf(currentPage));
            bundleSyncAdapter.putInt(CatalogSyncConstants.SYNC_PARAM_PAGE_SIZE, Integer.valueOf(pageSize));
        }

        break;

    // Getting a specific data detail
    case CatalogContract.Provider.CODE_DATA_ID:
    case CatalogContract.Provider.CODE_DATA_DETAILS_ID:
        tableName = CatalogContract.DataBaseDataDetails.TABLE_NAME;
        where = CatalogContract.DataBaseDataDetails.TABLE_NAME + "."
                + CatalogContract.DataBaseDataDetails.ATT_DATA_ID + "='" + lastPathSegment + "'";

        // Bundle information for the syncing part
        bundleSyncAdapter.putString(CatalogSyncConstants.SYNC_PARAM_DATA_ID, lastPathSegment);

        // We don't load the variants for a specific data
        bundleSyncAdapter.putBoolean(CatalogSyncConstants.SYNC_PARAM_LOAD_VARIANTS, false);
        break;

    default:
        Log.e(TAG, "URI not recognized" + uri.toString());
        throw new IllegalArgumentException("URI not recognized" + uri.toString());

    }

    // We do the query by joining the data to the group
    Cursor cursor = sqLiteDatabase.rawQuery("SELECT * FROM " + tableName + " INNER JOIN "
            + CatalogContract.DataBaseDataLinkGroup.TABLE_NAME + " ON " + tableName + "."
            + CatalogContract.DataBaseData.ATT_DATA_ID + "=" + CatalogContract.DataBaseDataLinkGroup.TABLE_NAME
            + "." + CatalogContract.DataBaseDataLinkGroup.ATT_DATA_ID + " WHERE " + where + order, null);

    // Register the cursor to watch the uri for changes
    cursor.setNotificationUri(getContext().getContentResolver(), uri);

    // Existing data
    if (cursor.getCount() > 0) {
        // TODO - For now we check if one the items is out-of-sync and we sync all of them if this is the case
        // Future - Check every out-of-date items and sync them
        cursor.moveToLast();
        int status = cursor.getInt(cursor.getColumnIndex(CatalogContract.DataBaseData.ATT_STATUS));
        cursor.moveToFirst();

        // Data expired, we request a sync
        if (status == CatalogContract.SyncStatus.OUTOFDATE.getValue()) {
            Log.i(TAG, "Data for " + uri.toString() + " is out-of-date, requesting a sync");
            requestSync(bundleSyncAdapter);

            // TODO - the uptodate/outofdate should be done in the sync adapter
            // We up-to-date all the data in case the sync does not return any results (we base our out of sync on the last item of the cursor)
            if (URI_MATCHER.match(uri) == CatalogContract.Provider.CODE_GROUP_ID) {
                updateInternalDataSyncStatus(cursor, tableName, SyncStatus.UPTODATE);
            }
        }
        // Data updated, we invalidate the data
        else {
            Log.i(TAG, "Data for " + uri.toString() + " is up-of-date, invalidating it");
            updateInternalDataSyncStatus(cursor, tableName, SyncStatus.OUTOFDATE);
        }

    }
    // No data found, we request a sync if it's not already up-to-date
    else {
        boolean triggerSyncAdapter;

        switch (URI_MATCHER.match(uri)) {

        // Saving the sync info for the group
        case CatalogContract.Provider.CODE_GROUP_ID:
            triggerSyncAdapter = updateTrackSyncStatus(CatalogContract.Provider.getUriSyncGroup(authority),
                    CatalogContract.DataBaseSyncStatusGroup.ATT_GROUP_ID,
                    CatalogContract.DataBaseSyncStatusGroup.TABLE_NAME, lastPathSegment);

            break;

        // Saving the sync info for the data
        case CatalogContract.Provider.CODE_DATA_ID:
            triggerSyncAdapter = updateTrackSyncStatus(CatalogContract.Provider.getUriData(authority),
                    CatalogContract.DataBaseData.ATT_DATA_ID, CatalogContract.DataBaseDataSimple.TABLE_NAME,
                    lastPathSegment);
            break;

        // Saving the sync info for the data details
        case CatalogContract.Provider.CODE_DATA_DETAILS_ID:
            triggerSyncAdapter = updateTrackSyncStatus(CatalogContract.Provider.getUriDataDetails(authority),
                    CatalogContract.DataBaseData.ATT_DATA_ID, CatalogContract.DataBaseDataDetails.TABLE_NAME,
                    lastPathSegment);
            break;

        default:
            Log.e(TAG, "URI not recognized" + uri.toString());
            throw new IllegalArgumentException("URI not recognized" + uri.toString());

        }

        // Trigger the sync adapter
        if (triggerSyncAdapter) {
            Log.i(TAG, "No data found for " + uri.toString() + " and data out-of-date, requesting a sync");
            requestSync(bundleSyncAdapter);
        } else {
            Log.i(TAG, "No data found for " + uri.toString() + " and data up-to-date");
        }

    }

    return cursor;
}

From source file:com.speed.traquer.app.TraqComplaintTaxi.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_traq_complaint_taxi);
    easyTracker = EasyTracker.getInstance(TraqComplaintTaxi.this);
    //onCreateView(savedInstanceState);
    //InitialSetupUI();

    //Added UIHelper
    uiHelper = new UiLifecycleHelper(this, null);
    uiHelper.onCreate(savedInstanceState);

    inputTaxi = (EditText) findViewById(R.id.taxi_id);
    taxiDriver = (EditText) findViewById(R.id.taxi_driver);
    taxiLic = (EditText) findViewById(R.id.taxi_license);
    geoLat = (TextView) findViewById(R.id.geoLat);
    geoLong = (TextView) findViewById(R.id.geoLong);
    editDate = (EditText) findViewById(R.id.editDate);
    editTime = (EditText) findViewById(R.id.editTime);
    editCurrTime = (EditText) findViewById(R.id.editCurrTime);
    complainSend = (Button) findViewById(R.id.complain_send);

    ProgressBar barProgress = (ProgressBar) findViewById(R.id.progressLoading);
    ProgressBar barProgressFrom = (ProgressBar) findViewById(R.id.progressLoadingFrom);
    ProgressBar barProgressTo = (ProgressBar) findViewById(R.id.progressLoadingTo);

    actv_comp_taxi = (AutoCompleteTextView) findViewById(R.id.search_taxi_comp);
    SuggestionAdapter sa = new SuggestionAdapter(this, actv_comp_taxi.getText().toString(), taxiUrl,
            "compcode");
    sa.setLoadingIndicator(barProgress);
    actv_comp_taxi.setAdapter(sa);/* ww  w. jav  a 2s.  c o  m*/

    actv_from = (AutoCompleteTextView) findViewById(R.id.search_from);
    SuggestionAdapter saFrom = new SuggestionAdapter(this, actv_from.getText().toString(), locUrl, "location");
    saFrom.setLoadingIndicator(barProgressFrom);
    actv_from.setAdapter(saFrom);

    actv_to = (AutoCompleteTextView) findViewById(R.id.search_to);
    SuggestionAdapter saTo = new SuggestionAdapter(this, actv_to.getText().toString(), locUrl, "location");
    saTo.setLoadingIndicator(barProgressTo);
    actv_to.setAdapter(saTo);

    /*if(isNetworkConnected()) {
    new getTaxiComp().execute(new ApiConnector());
    }*/

    //Setting Fonts
    String fontPath = "fonts/segoeuil.ttf";
    Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
    complainSend.setTypeface(tf);
    inputTaxi.setTypeface(tf);
    editDate.setTypeface(tf);
    editTime.setTypeface(tf);
    actv_comp_taxi.setTypeface(tf);
    actv_to.setTypeface(tf);
    actv_from.setTypeface(tf);
    taxiDriver.setTypeface(tf);
    taxiLic.setTypeface(tf);

    TextView txtComp = (TextView) findViewById(R.id.taxi_comp);
    txtComp.setTypeface(tf);

    TextView txtTaxiDriver = (TextView) findViewById(R.id.txt_taxi_driver);
    txtTaxiDriver.setTypeface(tf);

    TextView txtTaxiLic = (TextView) findViewById(R.id.txt_taxi_license);
    txtTaxiLic.setTypeface(tf);

    TextView txtNumber = (TextView) findViewById(R.id.taxi_number);
    txtNumber.setTypeface(tf);

    TextView txtTo = (TextView) findViewById(R.id.to);
    txtTo.setTypeface(tf);

    TextView txtDate = (TextView) findViewById(R.id.date);
    txtDate.setTypeface(tf);

    TextView txtTime = (TextView) findViewById(R.id.time);
    txtTime.setTypeface(tf);

    gLongitude = this.getIntent().getExtras().getDouble("Longitude");
    gLatitude = this.getIntent().getExtras().getDouble("Latitude");
    speedTaxiExceed = this.getIntent().getExtras().getDouble("SpeedTaxiExceed");

    isTwitterSelected = false;
    isFacebookSelected = false;
    isDefaultSelected = false;
    isSmsSelected = false;

    geoLat.setText(Double.toString(gLatitude));
    geoLong.setText(Double.toString(gLongitude));

    rateBtnBus = (ImageButton) findViewById(R.id.btn_rate_bus);

    rateBtnBus.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if (actv_comp_taxi.length() != 0) {
                final AlertDialog.Builder alertBox = new AlertDialog.Builder(TraqComplaintTaxi.this);
                alertBox.setIcon(R.drawable.info_icon);
                alertBox.setCancelable(false);
                alertBox.setTitle("Do you want to cancel complaint?");
                alertBox.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface arg0, int arg1) {
                        // finish used for destroyed activity
                        easyTracker.send(MapBuilder
                                .createEvent("Complaint", "Cancel Complaint (Yes)", "Complaint event", null)
                                .build());
                        finish();
                    }
                });

                alertBox.setNegativeButton("No", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int arg1) {
                        easyTracker.send(MapBuilder
                                .createEvent("Complaint", "Cancel Complaint (No)", "Complaint event", null)
                                .build());
                        dialog.cancel();
                    }
                });

                alertBox.show();
            } else {
                Intent intent = new Intent(getApplicationContext(), TraqComplaint.class);
                intent.putExtra("Latitude", gLatitude);
                intent.putExtra("Longitude", gLongitude);
                intent.putExtra("SpeedBusExceed", speedTaxiExceed);
                startActivity(intent);
            }
        }
    });

    complainSend.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            String taxi_id = inputTaxi.getText().toString().toUpperCase();
            String taxi_comp = actv_comp_taxi.getText().toString();

            /*if(taxi_comp.length() == 0){
            Toast.makeText(TraqComplaintTaxi.this, "Taxi Company is required!", Toast.LENGTH_SHORT).show();
            }else */
            if (taxi_comp.length() < 2) {
                Toast.makeText(TraqComplaintTaxi.this, "Invalid Taxi Company.", Toast.LENGTH_SHORT).show();
            } else if (taxi_id.length() == 0) {
                Toast.makeText(TraqComplaintTaxi.this, "Taxi Plate Number is required!", Toast.LENGTH_SHORT)
                        .show();
            } else if (taxi_id.length() < 7) {
                Toast.makeText(TraqComplaintTaxi.this, "Invalid Taxi Number.", Toast.LENGTH_SHORT).show();
            } else {
                easyTracker.send(
                        MapBuilder.createEvent("Complaint", "Dialog Prompt", "Complaint event", null).build());
                PromptCustomDialog();
            }
        }
    });
    setCurrentDateOnView();
    getCurrentTime();

    //Shi Chuan's Code

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    cd = new ConnectionDetector(getApplicationContext());

    // Check if Internet present
    if (!cd.isConnectingToInternet()) {
        // Internet Connection is not present
        alert.showAlertDialog(TraqComplaintTaxi.this, "Internet Connection Error",
                "Please connect to working Internet connection", false);
        // stop executing code by return
        return;
    }

    // Check if twitter keys are set
    if (TWITTER_CONSUMER_KEY.trim().length() == 0 || TWITTER_CONSUMER_SECRET.trim().length() == 0) {
        // Internet Connection is not present
        alert.showAlertDialog(TraqComplaintTaxi.this, "Twitter oAuth tokens",
                "Please set your twitter oauth tokens first!", false);
        // stop executing code by return
        return;
    }

    // Shared Preferences
    mSharedPreferences = getApplicationContext().getSharedPreferences("MyPref", 0);

    /** This if conditions is tested once is
     * redirected from twitter page. Parse the uri to get oAuth
     * Verifier
     * */

    if (!isTwitterLoggedInAlready()) {
        Uri uri = getIntent().getData();
        if (uri != null && uri.toString().startsWith(TWITTER_CALLBACK_URL)) {
            // oAuth verifier
            String verifier = uri.getQueryParameter(URL_TWITTER_OAUTH_VERIFIER);

            try {
                // Get the access token
                AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier);

                // Shared Preferences
                SharedPreferences.Editor e = mSharedPreferences.edit();

                // After getting access token, access token secret
                // store them in application preferences
                e.putString(PREF_KEY_OAUTH_TOKEN, accessToken.getToken());
                e.putString(PREF_KEY_OAUTH_SECRET, accessToken.getTokenSecret());
                // Store login status - true
                e.putBoolean(PREF_KEY_TWITTER_LOGIN, true);
                e.commit(); // save changes

                Log.e("Twitter OAuth Token", "> " + accessToken.getToken());

                // Getting user details from twitter
                // For now i am getting his name only
                long userID = accessToken.getUserId();
                User user = twitter.showUser(userID);

                String username = user.getName();
                String description = user.getDescription();

                // Displaying in xml ui
                //lblUserName.setText(Html.fromHtml("<b>Welcome " + username + "</b>" + description));
            } catch (Exception e) {
                // Check log for login errors
                Log.e("Twitter Login Error", "> " + e.getMessage());
            }
        }
    }

    //LocationManager lm = (LocationManager)  this.getSystemService(Context.LOCATION_SERVICE);
    //LocationListener ll = new passengerLocationListener();
    //lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);

}

From source file:com.deliciousdroid.activity.BrowseBookmarks.java

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

    Intent intent = getIntent();/*from ww w  .  j  a  va 2 s .  co  m*/

    Uri data = intent.getData();
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction t = fm.beginTransaction();

    Fragment bookmarkFrag;

    if (fm.findFragmentById(R.id.listcontent) == null) {
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA);

            if (searchData != null) {
                tagname = searchData.getString("tagname");
                username = searchData.getString("username");
                unread = searchData.getBoolean("unread");
            }

            query = intent.getStringExtra(SearchManager.QUERY);

            if (intent.hasExtra("username")) {
                username = intent.getStringExtra("username");
            }

            if (data != null && data.getUserInfo() != null) {
                username = data.getUserInfo();
            }
        } else {
            if (data != null) {
                if (data.getUserInfo() != "") {
                    username = data.getUserInfo();
                } else
                    username = mAccount.name;
                tagname = data.getQueryParameter("tagname");
                unread = data.getQueryParameter("unread") != null;
                path = data.getPath();
            }
        }

        if (isMyself()) {
            bookmarkFrag = new BrowseBookmarksFragment();
        } else {
            bookmarkFrag = new BrowseBookmarkFeedFragment();
        }

        t.add(R.id.listcontent, bookmarkFrag);
    } else {
        if (savedInstanceState != null) {
            username = savedInstanceState.getString(STATE_USERNAME);
            tagname = savedInstanceState.getString(STATE_TAGNAME);
            unread = savedInstanceState.getBoolean(STATE_UNREAD);
            query = savedInstanceState.getString(STATE_QUERY);
            path = savedInstanceState.getString(STATE_PATH);
        }

        bookmarkFrag = fm.findFragmentById(R.id.listcontent);
    }

    if (isMyself()) {
        if (query != null && !query.equals("")) {
            ((BrowseBookmarksFragment) bookmarkFrag).setSearchQuery(query, username, tagname, unread);
        } else {
            ((BrowseBookmarksFragment) bookmarkFrag).setQuery(username, tagname, unread);
        }
    } else {
        if (query != null && !query.equals("")) {
            ((BrowseBookmarkFeedFragment) bookmarkFrag).setQuery(username, tagname);
        } else {
            ((BrowseBookmarkFeedFragment) bookmarkFrag).setQuery(username, query);
        }
    }

    BrowseTagsFragment tagFrag = (BrowseTagsFragment) fm.findFragmentById(R.id.tagcontent);
    if (tagFrag != null) {
        tagFrag.setAccount(username);
    }

    if (path != null && path.contains("tags")) {
        t.hide(fm.findFragmentById(R.id.maincontent));
        findViewById(R.id.panel_collapse_button).setVisibility(View.GONE);
    } else {
        if (tagFrag != null) {
            t.hide(tagFrag);
        }
    }

    Fragment addFrag = fm.findFragmentById(R.id.addcontent);
    if (addFrag != null) {
        t.hide(addFrag);
    }

    t.commit();
}

From source file:com.google.android.dialer.provider.DialerProvider.java

@Override
public Cursor query(Uri uri, final String[] projection, String selection, String[] selectionArgs,
        String sortOrder) {//from   w  ww. j  a  v a2  s.co m
    if (Log.isLoggable("DialerProvider", 2)) {
        Log.v("DialerProvider", "query: " + uri);
    }

    switch (sURIMatcher.match(uri)) {
    case 0:
        Context context = getContext();
        if (!GoogleLocationSettingHelper.isGoogleLocationServicesEnabled(context)
                || !GoogleLocationSettingHelper.isSystemLocationSettingEnabled(context)) {
            if (Log.isLoggable("DialerProvider", Log.VERBOSE)) {
                Log.v("DialerProvider", "Location settings is disabled, ignoring query.");
            }
            return null;
        }

        final Location lastLocation = getLastLocation();
        if (lastLocation == null) {
            if (Log.isLoggable("DialerProvider", Log.VERBOSE)) {
                Log.v("DialerProvider", "No location available, ignoring query.");
            }
            return null;
        }

        final String filter = Uri.encode(uri.getLastPathSegment());
        String limit = uri.getQueryParameter("limit");

        try {
            final int limitInt;
            if (limit == null) {
                limitInt = -1;
            } else {
                limitInt = Integer.parseInt(limit);
            }

            return execute(new Callable<Cursor>() {
                @Override
                public Cursor call() {
                    return handleFilter(projection, filter, limitInt, lastLocation);
                }
            }, "FilterThread", 10000L, TimeUnit.MILLISECONDS);
        } catch (NumberFormatException e) {
            Log.e("DialerProvider", "query: invalid limit parameter: '" + limit + "'");
        }

        break;
    }

    // TODO: Is this acceptable?
    return null;
}

From source file:com.klinker.android.twitter.activities.search.SearchPager.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        searchQuery = intent.getStringExtra(SearchManager.QUERY);

        SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY,
                MySuggestionsProvider.MODE);

        if (searchQuery.contains("#")) {
            suggestions.saveRecentQuery(searchQuery.replaceAll("\"", ""), null);
        } else {//from   ww w .  j a  v a 2 s .  com
            suggestions.saveRecentQuery(searchQuery, null);
        }

        searchQuery += " -RT";
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri uri = intent.getData();
        String uriString = uri.toString();
        if (uriString.contains("status/")) {
            long id;
            String replace = uriString.substring(uriString.indexOf("status")).replace("status/", "")
                    .replaceAll("photo/*", "");
            if (replace.contains("/")) {
                replace = replace.substring(0, replace.indexOf("/"));
            } else if (replace.contains("?")) {
                replace = replace.substring(0, replace.indexOf("?"));
            }
            try {
                id = Long.parseLong(replace);
            } catch (Exception e) {
                id = 0l;
            }
            searchQuery = id + "";
            onlyStatus = true;
        } else if (!uriString.contains("q=") && !uriString.contains("screen_name%3D")) {
            // going to try searching for users i guess
            String name = uriString.substring(uriString.indexOf(".com/"));
            name = name.replaceAll("/", "").replaceAll(".com", "");
            searchQuery = name;
            onlyProfile = true;
        } else if (uriString.contains("q=")) {
            try {
                String search = uri.getQueryParameter("q");

                if (search != null) {
                    searchQuery = search;
                    SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                            MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);

                    if (searchQuery.contains("#")) {
                        suggestions.saveRecentQuery(searchQuery.replaceAll("\"", ""), null);
                    } else {
                        suggestions.saveRecentQuery(searchQuery, null);
                    }

                    searchQuery += " -RT";
                } else {
                    searchQuery = "";
                }

            } catch (Exception e) {

            }
        } else {
            try {
                String search = uriString;

                search = search.substring(search.indexOf("screen_name%3D") + 14);
                search = search.substring(0, search.indexOf("%"));

                if (search != null) {
                    searchQuery = search;

                    SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                            MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);

                    if (searchQuery.contains("#")) {
                        suggestions.saveRecentQuery(searchQuery.replaceAll("\"", ""), null);
                    } else {
                        suggestions.saveRecentQuery(searchQuery, null);
                    }

                    searchQuery += " -RT";
                } else {
                    searchQuery = "";
                }

                onlyProfile = true;
            } catch (Exception e) {

            }
        }
    }
}

From source file:com.klinker.android.twitter.ui.search.SearchPager.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        searchQuery = intent.getStringExtra(SearchManager.QUERY);

        SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY,
                MySuggestionsProvider.MODE);
        suggestions.saveRecentQuery(searchQuery, null);
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri uri = intent.getData();
        String uriString = uri.toString();
        if (uriString.contains("status/")) {
            long id;
            String replace = uriString.substring(uriString.indexOf("status")).replace("status/", "")
                    .replaceAll("photo/*", "");
            if (replace.contains("/")) {
                replace = replace.substring(0, replace.indexOf("/"));
            } else if (replace.contains("?")) {
                replace = replace.substring(0, replace.indexOf("?"));
            }//  ww w . j a v a 2s. com
            try {
                id = Long.parseLong(replace);
            } catch (Exception e) {
                id = 0l;
            }
            searchQuery = id + "";
            onlyStatus = true;
        } else if (!uriString.contains("q=") && !uriString.contains("screen_name%3D")) { // going to try searching for users i guess
            String name = uriString.substring(uriString.indexOf(".com/"));
            name = name.replaceAll("/", "").replaceAll(".com", "");
            searchQuery = name;
            onlyProfile = true;
            Log.v("talon_searching", "only profile");
        } else if (uriString.contains("q=")) {
            try {
                String search = uri.getQueryParameter("q");

                if (search != null) {
                    searchQuery = search;
                    SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                            MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
                    suggestions.saveRecentQuery(searchQuery, null);
                } else {
                    searchQuery = "";
                }

            } catch (Exception e) {

            }
        } else {
            try {
                String search = uriString;

                search = search.substring(search.indexOf("screen_name%3D") + 14);
                search = search.substring(0, search.indexOf("%"));

                if (search != null) {
                    searchQuery = search;

                    SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                            MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
                    suggestions.saveRecentQuery(searchQuery, null);
                } else {
                    searchQuery = "";
                }

                onlyProfile = true;
            } catch (Exception e) {

            }
        }
    }
}

From source file:com.vuze.android.remote.activity.IntentHandler.java

private boolean handleIntent(Intent intent, Bundle savedInstanceState) {
    boolean forceProfileListOpen = (intent.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_TOP) > 0;

    if (AndroidUtils.DEBUG) {
        Log.d(TAG, "ForceOpen? " + forceProfileListOpen);
        Log.d(TAG, "IntentHandler intent = " + intent);
    }//from   w ww. ja v  a2  s. c  o m

    appPreferences = VuzeRemoteApp.getAppPreferences();

    Uri data = intent.getData();
    if (data != null) {
        try {
            // check for vuze://remote//*
            String scheme = data.getScheme();
            String host = data.getHost();
            String path = data.getPath();
            if ("vuze".equals(scheme) && "remote".equals(host) && path != null && path.length() > 1) {
                String ac = path.substring(1);
                if (AndroidUtils.DEBUG) {
                    Log.d(TAG, "got ac '" + ac + "' from " + data);
                }

                intent.setData(null);
                if (ac.equals("cmd=advlogin")) {
                    DialogFragmentGenericRemoteProfile dlg = new DialogFragmentGenericRemoteProfile();
                    AndroidUtils.showDialog(dlg, getSupportFragmentManager(), "GenericRemoteProfile");
                    forceProfileListOpen = true;
                } else if (ac.length() < 100) {
                    RemoteProfile remoteProfile = new RemoteProfile("vuze", ac);
                    new RemoteUtils(this).openRemote(remoteProfile, true);
                    finish();
                    return true;
                }
            }

            // check for http[s]://remote.vuze.com/ac=*
            if (host != null && host.equals("remote.vuze.com") && data.getQueryParameter("ac") != null) {
                String ac = data.getQueryParameter("ac");
                if (AndroidUtils.DEBUG) {
                    Log.d(TAG, "got ac '" + ac + "' from " + data);
                }
                intent.setData(null);
                if (ac.length() < 100) {
                    RemoteProfile remoteProfile = new RemoteProfile("vuze", ac);
                    new RemoteUtils(this).openRemote(remoteProfile, true);
                    finish();
                    return true;
                }
            }
        } catch (Exception e) {
            if (AndroidUtils.DEBUG) {
                e.printStackTrace();
            }
        }
    }

    if (!forceProfileListOpen) {
        int numRemotes = getRemotesWithLocal().length;
        if (numRemotes == 0) {
            // New User: Send them to Login (Account Creation)
            Intent myIntent = new Intent(Intent.ACTION_VIEW, null, this, LoginActivity.class);
            myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);

            startActivity(myIntent);
            finish();
            return true;
        } else if (numRemotes == 1 || intent.getData() == null) {
            try {
                RemoteProfile remoteProfile = appPreferences.getLastUsedRemote();
                if (remoteProfile != null) {
                    if (savedInstanceState == null) {
                        new RemoteUtils(this).openRemote(remoteProfile, true);
                        finish();
                        return true;
                    }
                } else {
                    Log.d(TAG, "Has Remotes, but no last remote");
                }
            } catch (Throwable t) {
                if (AndroidUtils.DEBUG) {
                    Log.e(TAG, "onCreate", t);
                }
                VuzeEasyTracker.getInstance(this).logError(t);
            }
        }
    }
    return false;
}