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.msplearning.android.ext.TwitterWebOAuthActivity.java

@Override
public void onStart() {
    super.onStart();
    Uri uri = this.getIntent().getData();
    if (uri != null) {
        String oauthVerifier = uri.getQueryParameter("oauth_verifier");

        if (oauthVerifier != null) {
            this.getWebView().clearView();
            new TwitterPostConnectTask().execute(oauthVerifier);
        }//from w  ww . j  av  a2 s. com
    } else {
        new TwitterPreConnectTask().execute();
    }
}

From source file:com.klinker.android.spotify.fragment.BaseOAuthFragment.java

/**
 * Process information encoded in URL once a page has finished loading to see if we are done
 */// w  w w. j a  v  a 2 s.c om
protected boolean processPageFinished(String url, boolean authComplete) {
    if (url.contains("?code=") && !authComplete) {
        Uri uri = Uri.parse(url);
        String authCode = uri.getQueryParameter("code");
        Log.v(TAG, "auth code: " + authCode);
        getTokenAsyncTask(authCode).execute();
        authComplete = true;
    } else if (url.contains("error=access_denied")) {
        Log.v(TAG, "ACCESS_DENIED_HERE");
        Toast.makeText(getActivity(), getString(R.string.auth_failed), Toast.LENGTH_SHORT).show();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                getActivity().finish();
            }
        }, 500);
        authComplete = true;
    }

    return authComplete;
}

From source file:com.facebook.GraphRequestTest.java

@Test
public void testBuildsClientTokenIfNeeded() throws Exception {
    GraphRequest requestMe = new GraphRequest(null, "TourEiffel");
    HttpURLConnection connection = GraphRequest.toHttpConnection(requestMe);

    assertTrue(connection != null);//from www .j  ava2s. co m

    Uri uri = Uri.parse(connection.getURL().toString());
    String accessToken = uri.getQueryParameter("access_token");
    assertNotNull(accessToken);
    assertTrue(accessToken.contains(FacebookSdk.getApplicationId()));
    assertTrue(accessToken.contains(FacebookSdk.getClientToken()));
}

From source file:com.davidivins.checkin4me.foursquare.FoursquareOAuthConnector.java

/**
 * isSuccessfulAuthorizationResponse/* ww  w  .j a  v a 2s .  c  o  m*/
 * 
 * @param response
 * @return boolean
 */
public boolean isSuccessfulAuthorizationResponse(Uri response) {
    boolean is_successful = false;

    if ((null != response) && (response.getQueryParameter("code") != null))
        is_successful = true;

    Log.i(TAG, "isSuccessfulAuthorizationResponse = " + is_successful);
    return is_successful;
}

From source file:eu.masconsult.bgbanking.activity.HomeActivity.java

private void trackReferrer() {
    // Get the intent that started this Activity.
    Intent intent = getIntent();// w  ww.j a va  2s . c  om
    Uri uri = intent.getData();

    if (uri != null) {
        if (uri.getQueryParameter("utm_source") != null) {
            // Use campaign parameters if available.
            EasyTracker.getTracker().setCampaign(uri.getPath());
        } else if (uri.getQueryParameter("referrer") != null) {
            // Otherwise, try to find a referrer parameter.
            EasyTracker.getTracker().setReferrer(uri.getQueryParameter("referrer"));
        }
    }
}

From source file:com.yozio.android.YozioApiServiceImplTest.java

public void testGetYozioLinkWithMultipleDestUrls() {
    String expectedYozioLink = "www.foobar.com";
    String expectedIosDestUrl = "www.ios.com";
    String expectedAndroidDestUrl = "www.android.com";
    String expectedNonMobileDestUrl = "www.nonmobile.com";

    fakeHttpClient.setHttpResonse(createJsonHttpResponse(200, "url", expectedYozioLink));

    String yozioLink = apiService.getYozioLink(APP_KEY, UDID, LOOP_NAME, expectedIosDestUrl,
            expectedAndroidDestUrl, expectedNonMobileDestUrl, null, null);

    Uri requestUri = fakeHttpClient.getLastRequestUri();
    String iosDestUrl = requestUri.getQueryParameter("ios_dest_url");
    String androidDestUrl = requestUri.getQueryParameter("android_dest_url");
    String nonMobileDestUrl = requestUri.getQueryParameter("non_mobile_dest_url");

    assertEquals(expectedIosDestUrl, iosDestUrl);
    assertEquals(expectedAndroidDestUrl, androidDestUrl);
    assertEquals(expectedNonMobileDestUrl, nonMobileDestUrl);
    assertEquals(expectedYozioLink, yozioLink);
}

From source file:com.facebook.GraphRequestTest.java

@Test
public void testSingleGetToHttpRequest() throws Exception {
    GraphRequest requestMe = new GraphRequest(null, "TourEiffel");
    HttpURLConnection connection = GraphRequest.toHttpConnection(requestMe);

    assertTrue(connection != null);/*from www  .j  av a 2 s  . c o m*/

    assertEquals("GET", connection.getRequestMethod());
    assertEquals("/" + ServerProtocol.getAPIVersion() + "/TourEiffel", connection.getURL().getPath());

    assertTrue(connection.getRequestProperty("User-Agent").startsWith("FBAndroidSDK"));

    Uri uri = Uri.parse(connection.getURL().toString());
    assertEquals("android", uri.getQueryParameter("sdk"));
    assertEquals("json", uri.getQueryParameter("format"));
}

From source file:com.ibm.cloud.appid.android.internal.authorizationmanager.ChromeTabActivity.java

private void onBroadcastReceived(Intent intent) {
    Uri uri = intent.getParcelableExtra(ChromeTabActivity.EXTRA_REDIRECT_URI);
    String url = uri.toString();//w w w.j  a  v  a2s .c  o  m
    String code = uri.getQueryParameter("code");
    String error = uri.getQueryParameter("error");
    String flow = uri.getQueryParameter("flow");

    logger.info("onBroadcastReceived: " + url);

    Intent clearTopActivityIntent = new Intent(postAuthorizationIntent);
    clearTopActivityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    if (url.startsWith(redirectUrl) && code != null) {
        logger.debug("Grant code received from authorization server.");
        oAuthManager.getTokenManager().obtainTokensAuthCode(code, authorizationListener);
        startActivity(clearTopActivityIntent);
    } else if (url.startsWith(redirectUrl) && error != null) {
        if (error.equals("invalid_client")) {
            oAuthManager.getRegistrationManager().clearRegistrationData();
            oAuthManager.getAuthorizationManager().launchAuthorizationUI(this, authorizationListener);
        } else {
            String errorCode = uri.getQueryParameter("error_code");
            String errorDescription = uri.getQueryParameter("error_description");
            logger.error("Failed to obtain access and identity tokens, error: " + error);
            logger.error("errorCode: " + errorCode);
            logger.error("errorDescription: " + errorDescription);
            authorizationListener.onAuthorizationFailure(new AuthorizationException(error));
            startActivity(clearTopActivityIntent);
        }
    } else if (url.startsWith(redirectUrl) && (FORGOT_PASSWORD.equals(flow) || SIGN_UP.equals(flow))) {
        logger.debug("onBroadcastReceived: end of flow: " + flow);
        authorizationListener.onAuthorizationSuccess(null, null, null);
        startActivity(clearTopActivityIntent);
    } else {
        logger.debug("onBroadcastReceived: no match case");
        authorizationListener.onAuthorizationFailure(new AuthorizationException("Bad callback uri"));
        startActivity(clearTopActivityIntent);
    }
}

From source file:org.mariotaku.twidere.activity.MapViewerActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_viewer);
    final Uri uri = getIntent().getData();
    if (uri == null || !AUTHORITY_MAP.equals(uri.getAuthority())) {
        finish();//from  www .  ja  v  a  2  s.  com
        return;
    }
    final Bundle bundle = new Bundle();
    final String param_lat = uri.getQueryParameter(QUERY_PARAM_LAT);
    final String param_lng = uri.getQueryParameter(QUERY_PARAM_LNG);
    if (param_lat == null || param_lng == null) {
        finish();
        return;
    }
    try {
        bundle.putDouble(INTENT_KEY_LATITUDE, Double.valueOf(param_lat));
        bundle.putDouble(INTENT_KEY_LONGITUDE, Double.valueOf(param_lng));
    } catch (final NumberFormatException e) {
        finish();
        return;
    }
    final Fragment fragment = isNativeMapSupported() ? new NativeMapFragment() : new WebMapFragment();
    fragment.setArguments(bundle);
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.map_frame, fragment).commit();
}

From source file:com.example.easyvoice.MessageDetail.java

@Override
protected void onStart() {
    super.onStart();
    Log.d(getClass().getSimpleName(), "onStart");

    String action = getIntent().getAction();
    String data = getIntent().getDataString();

    if (action.equalsIgnoreCase(Intent.ACTION_EDIT)) {
        Log.d(getClass().getSimpleName(), "parsing uri, data is " + data);

        Uri uri = Uri.parse(data);
        String qp = uri.getQueryParameter("msgid");
        msgId = Integer.parseInt(qp);

        Log.d(getClass().getSimpleName(), "Loading msg " + qp);

        LoadMessage(msgId);//from  ww w  .  ja  va2  s.c o m

        saveBtn.setText(getString(R.string.update_button));
        //         saveBtn.setOnClickListener (new View.OnClickListener() {
        //            public void onClick(View v) {                 // Perform action on click             }
        //               onUpdate(v);
        //            }
        //         });
    }

    Log.i(getClass().getSimpleName(), "onStart, action is " + action + ", data is " + data);
}