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.androidquery.simplefeed.fragments.NotificationFragment.java

private String getVideoId(FeedItem item, String link, Uri uri) {

    String result = null;//from  ww w  . j av  a  2  s .co m

    try {

        if (link.contains("photo.php")) {
            result = uri.getQueryParameter("v");
        }

    } catch (Exception e) {
        AQUtility.report(e);
    }

    return result;
}

From source file:com.ap.jesus.migsv2.CamActivity.java

@Override
public ArchitectUrlListener getUrlListener() {
    return new ArchitectUrlListener() {

        @Override/*  www . j a  va 2s  . c om*/
        public boolean urlWasInvoked(String uriString) {
            Uri invokedUri = Uri.parse(uriString);

            // pressed "More" button on POI-detail panel
            if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) {
                final Intent poiDetailIntent = new Intent(CamActivity.this, PoiDetailActivity.class);
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_ID,
                        String.valueOf(invokedUri.getQueryParameter("id")));
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_TITILE,
                        String.valueOf(invokedUri.getQueryParameter("title")));
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_DESCR,
                        String.valueOf(invokedUri.getQueryParameter("description")));
                CamActivity.this.startActivity(poiDetailIntent);
                return true;
            }

            // pressed snapshot button. check if host is button to fetch e.g. 'architectsdk://button?action=captureScreen', you may add more checks if more buttons are used inside AR scene
            else if ("button".equalsIgnoreCase(invokedUri.getHost())) {
                CamActivity.this.architectView.captureScreen(
                        ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW,
                        new CaptureScreenCallback() {

                            @Override
                            public void onScreenCaptured(final Bitmap screenCapture) {
                                if (ContextCompat.checkSelfPermission(CamActivity.this,
                                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                                    CamActivity.this.screenCapture = screenCapture;
                                    ActivityCompat.requestPermissions(CamActivity.this,
                                            new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                                            WIKITUDE_PERMISSIONS_REQUEST_EXTERNAL_STORAGE);
                                } else {
                                    CamActivity.this.saveScreenCaptureToExternalStorage(screenCapture);
                                }
                            }
                        });
            }
            return true;
        }
    };
}

From source file:im.ene.lab.attiq.ui.activities.HomeActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQUEST_CODE_SEARCH:
        // reset the search icon which we hid
        View searchMenuView = mToolBar.findViewById(R.id.action_search);
        if (searchMenuView != null) {
            searchMenuView.setAlpha(1.f);
        }/*from  w ww. ja v  a 2 s. c om*/
        break;
    case REQUEST_CODE_LOGIN:
        if (resultCode == RESULT_OK && data != null) {
            String callback = data.getStringExtra(EXTRA_AUTH_CALLBACK);
            Uri callbackUri = Uri.parse(callback);
            final String code = callbackUri.getQueryParameter("code");
            ApiClient.accessToken(code).enqueue(mOnTokenCallback);
        }
        break;
    default:
        break;
    }
}

From source file:org.mariotaku.twidere.provider.TweetStoreProvider.java

private void onDatabaseUpdated(final Uri uri) {
    if (uri == null)
        return;//from   w w  w  . jav a  2s.  c  o  m
    if ("false".equals(uri.getQueryParameter(QUERY_PARAM_NOTIFY)))
        return;
    final Context context = getContext();
    switch (getTableId(uri)) {
    case URI_ACCOUNTS: {
        clearAccountColor();
        clearAccountName();
        context.sendBroadcast(new Intent(BROADCAST_ACCOUNT_LIST_DATABASE_UPDATED));
        break;
    }
    case URI_DRAFTS: {
        context.sendBroadcast(new Intent(BROADCAST_DRAFTS_DATABASE_UPDATED));
        break;
    }
    case URI_STATUSES:
    case URI_MENTIONS:
    case URI_DIRECT_MESSAGES_INBOX:
    case URI_DIRECT_MESSAGES_OUTBOX: {
        notifyForUpdatedUri(context, uri);
        break;
    }
    case URI_TRENDS_LOCAL: {
        context.sendBroadcast(new Intent(BROADCAST_TRENDS_UPDATED));
        break;
    }
    case URI_TABS: {
        context.sendBroadcast(new Intent(BROADCAST_TABS_UPDATED));
        break;
    }
    case URI_FILTERED_USERS:
    case URI_FILTERED_KEYWORDS:
    case URI_FILTERED_SOURCES: {
        context.sendBroadcast(new Intent(BROADCAST_FILTERS_UPDATED));
        break;
    }
    default:
        return;
    }
    context.sendBroadcast(new Intent(BROADCAST_DATABASE_UPDATED));
}

From source file:com.piser.apps.AppFive.CamActivity.java

@Override
public ArchitectView.ArchitectUrlListener getUrlListener() {
    return new ArchitectView.ArchitectUrlListener() {

        @Override/*from  w  w w. j  a va2 s. c  om*/
        public boolean urlWasInvoked(String uriString) {
            Uri invokedUri = Uri.parse(uriString);

            // pressed "More" button on POI-detail panel
            if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) {
                final Intent poiDetailIntent = new Intent(CamActivity.this, PoiDetailActivity.class);
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_ID,
                        String.valueOf(invokedUri.getQueryParameter("id")));
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_TITILE,
                        String.valueOf(invokedUri.getQueryParameter("title")));
                poiDetailIntent.putExtra(PoiDetailActivity.EXTRAS_KEY_POI_DESCR,
                        String.valueOf(invokedUri.getQueryParameter("description")));
                CamActivity.this.startActivity(poiDetailIntent);
                return true;
            }

            // pressed snapshot button. check if host is button to fetch e.g. 'architectsdk://button?action=captureScreen', you may add more checks if more buttons are used inside AR scene
            else if ("button".equalsIgnoreCase(invokedUri.getHost())) {
                CamActivity.this.architectView.captureScreen(
                        ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW,
                        new ArchitectView.CaptureScreenCallback() {

                            @Override
                            public void onScreenCaptured(final Bitmap screenCapture) {
                                if (ContextCompat.checkSelfPermission(CamActivity.this,
                                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                                    CamActivity.this.screenCapture = screenCapture;
                                    ActivityCompat.requestPermissions(CamActivity.this,
                                            new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                                            WIKITUDE_PERMISSIONS_REQUEST_EXTERNAL_STORAGE);
                                } else {
                                    CamActivity.this.saveScreenCaptureToExternalStorage(screenCapture);
                                }
                            }
                        });
            }
            return true;
        }
    };
}

From source file:com.microsoft.aad.adal.Oauth2.java

/**
 * parse final url for code(normal flow) or token(implicit flow) and then it
 * proceeds to next step./*from ww  w  .  j  av a2s . c o  m*/
 * 
 * @param authorizationUrl browser reached to this final url and it has code
 *            or token for next step
 * @return Token in the AuthenticationResult. Null result if response does
 *         not have protocol error.
 * @throws Exception
 */
public AuthenticationResult getToken(String authorizationUrl)
        throws IOException, AuthenticationServerProtocolException, AuthenticationException {

    if (StringExtensions.IsNullOrBlank(authorizationUrl)) {
        throw new IllegalArgumentException("authorizationUrl");
    }

    // Success
    HashMap<String, String> parameters = StringExtensions.getUrlParameters(authorizationUrl);
    String encodedState = parameters.get("state");
    String state = decodeProtocolState(encodedState);

    if (!StringExtensions.IsNullOrBlank(state)) {

        // We have encoded state at the end of the url
        Uri stateUri = Uri.parse("http://state/path?" + state);
        String authorizationUri = stateUri.getQueryParameter("a");
        String resource = stateUri.getQueryParameter("r");

        if (!StringExtensions.IsNullOrBlank(authorizationUri) && !StringExtensions.IsNullOrBlank(resource)
                && resource.equalsIgnoreCase(mRequest.getResource())) {

            AuthenticationResult result = processUIResponseParams(parameters);

            // Check if we have code
            if (result != null && result.getCode() != null && !result.getCode().isEmpty()) {

                // Get token and use external callback to set result
                return getTokenForCode(result.getCode());
            }

            return result;
        } else {
            throw new AuthenticationException(ADALError.AUTH_FAILED_BAD_STATE);
        }
    } else {

        // The response from the server had no state
        throw new AuthenticationException(ADALError.AUTH_FAILED_NO_STATE);
    }
}

From source file:com.androidclub.source.XmlDocumentProvider.java

/**
 * Query data from the XML document referenced in the URI.
 *
 * <p>The XML document can be a local resource or a file that will be downloaded from the
 * Internet. In the latter case, your application needs to request the INTERNET permission in
 * its manifest.</p>/*w  w w  .j  a va  2 s .com*/
 *
 * The URI will be of the form <code>content://xmldocument/?resource=R.xml.myFile</code> for a
 * local resource. <code>xmldocument</code> should match the authority declared for this
 * provider in your manifest. Internet documents are referenced using
 * <code>content://xmldocument/?url=</code> followed by an encoded version of the URL of your
 * document (see {@link Uri#encode(String)}).
 *
 * <p>The number of columns of the resulting Cursor is equal to the size of the projection
 * array plus one, named <code>_id</code> which will contain a unique row id (allowing the
 * Cursor to be used with a {@link CursorAdapter}). The other columns' names are the projection
 * patterns.</p>
 *
 * @param uri The URI of your local resource or Internet document.
 * @param projection A set of patterns that will be used to extract data from each selected
 * node. See class documentation for pattern syntax.
 * @param selection A selection pattern which will select the nodes that will create the
 * Cursor's rows. See class documentation for pattern syntax.
 * @param selectionArgs This parameter is ignored.
 * @param sortOrder The row order in the resulting cursor is determined from the node order in
 * the XML document. This parameter is ignored.
 * @return A Cursor or null in case of error.
 */
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {

    XmlPullParser parser = null;
    mHttpClient = null;

    final String url = uri.getQueryParameter("url");
    if (url != null) {
        parser = getUriXmlPullParser(url);
    } else {
        final String resource = uri.getQueryParameter("resource");
        if (resource != null) {
            Uri resourceUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
                    + getContext().getPackageName() + "/" + resource);
            parser = getResourceXmlPullParser(resourceUri);
        }
    }

    if (parser != null) {
        XMLCursor xmlCursor = new XMLCursor(selection, projection);
        try {
            xmlCursor.parseWith(parser);
            return xmlCursor;
        } catch (IOException e) {
            Log.w(LOG_TAG, "I/O error while parsing XML " + uri, e);
        } catch (XmlPullParserException e) {
            Log.w(LOG_TAG, "Error while parsing XML " + uri, e);
        } finally {
            if (mHttpClient != null) {
                mHttpClient.close();
            }
        }
    }

    return null;
}

From source file:com.google.android.apps.iosched.ui.gtv.GoogleTVSessionLivestreamActivity.java

/**
 * Updates views that rely on session data from explicit strings.
 *//*www  .  j  av a  2  s.  co m*/
private void updateSessionViews(final String youtubeUrl, final String title, final String sessionAbstract,
        final String hashTag) {

    if (youtubeUrl == null) {
        // Get out, nothing to do here
        Toast.makeText(this, R.string.error_tv_no_url, Toast.LENGTH_SHORT).show();
        LOGE(TAG, getString(R.string.error_tv_no_url));
        return;
    }

    String youtubeVideoId = youtubeUrl;
    if (youtubeUrl.startsWith("http")) {
        final Uri youTubeUri = Uri.parse(youtubeUrl);
        youtubeVideoId = youTubeUri.getQueryParameter("v");
    }
    playVideo(youtubeVideoId);

    if (mTrackPlay) {
        EasyTracker.getTracker().trackView("Live Streaming: " + title);
        LOGD("Tracker", "Live Streaming: " + title);
    }

    updateSessionSummaryFragment(title, sessionAbstract);

    mLiveListView.requestFocus();
}

From source file:com.takondi.tartt.ARActivity.java

private void processQr(String qrContent) {
    Uri qrUri = Uri.parse(qrContent);
    if (QR_TARTT_SCHEME.equals(qrUri.getScheme()) && QR_CHANNEL_HOST.equals(qrUri.getHost())
            && qrUri.getQueryParameter(Channel.CHANNEL_KEY) != null) {
        //we now might also be receiving a scanned qr/barcode out of an active world, so let's make sure to deactivate the world's AR
        loadDefaultWorld();//from  ww  w.  j  a va2  s.  c om

        mGuiHelper.changeGuiState(GUI_STATE.LOADING);
        TarttRequestOptions newConfig = Tartt
                .getInitialConfigForChannel(qrUri.getQueryParameter(Channel.CHANNEL_KEY));
        try {
            if (qrUri.getQueryParameter(Channel.STATE) != null) {
                newConfig.setState(TarttRequestOptions.State
                        .getStateForValue(Integer.valueOf(qrUri.getQueryParameter(Channel.STATE))));
            }
            if (qrUri.getQueryParameter(Channel.TARGET_TYPE) != null) {
                newConfig.setTargetType(
                        TarttRequestOptions.TargetType.valueOf(qrUri.getQueryParameter(Channel.TARGET_TYPE)));
            }
            if (qrUri.getQueryParameter(Channel.ENV_TYPE) != null) {
                newConfig.setEnvType(
                        TarttRequestOptions.EnvironmentType.valueOf(qrUri.getQueryParameter(Channel.ENV_TYPE)));
            }
            if (qrUri.getQueryParameter(Channel.TARGET_API) != null) {
                newConfig.setTargetApi(Integer.valueOf(qrUri.getQueryParameter(Channel.TARGET_API)));
            }
            if (qrUri.getQueryParameter(Channel.LANGUAGE) != null) {
                newConfig.setLanguage(qrUri.getQueryParameter(Channel.LANGUAGE));
            }
        } catch (NumberFormatException eNFE) {
            Log.e(TAG, "QR-Code contained invalid value for parameter (requires a number)");
        } catch (IllegalArgumentException eIAE) {
            Log.e(TAG, "QR-Code contained invalid value for a parameter (not in valid range)");
        }
        mChannelManager.fetchFilesForChannelWithConfig(newConfig, this);
    } else {
        mQrPlugin.activate();
    }
}

From source file:com.cyberprism.libin.artourist.ARActivity.java

@Override
public ArchitectView.ArchitectUrlListener getUrlListener() {
    return new ArchitectView.ArchitectUrlListener() {

        @Override/*from  www. java 2  s .com*/
        public boolean urlWasInvoked(String uriString) {
            Uri invokedUri = Uri.parse(uriString);

            // pressed "More" button on POI-detail panel
            if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) {
                final Intent poiDetailIntent = new Intent(ARActivity.this, SamplePoiDetailActivity.class);
                poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_ID,
                        String.valueOf(invokedUri.getQueryParameter("id")));
                poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_TITILE,
                        String.valueOf(invokedUri.getQueryParameter("title")));
                poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_DESCR,
                        String.valueOf(invokedUri.getQueryParameter("description")));
                poiDetailIntent.putExtra(SamplePoiDetailActivity.LATITUDE_KEY,
                        String.valueOf(invokedUri.getQueryParameter("latitude")));
                poiDetailIntent.putExtra(SamplePoiDetailActivity.LONGITUDE_KEY,
                        String.valueOf(invokedUri.getQueryParameter("longitude")));
                poiDetailIntent.putExtra(SamplePoiDetailActivity.IMAGE_KEY,
                        String.valueOf(invokedUri.getQueryParameter("image")));
                poiDetailIntent.putExtra(SamplePoiDetailActivity.IMAGE_RATING,
                        String.valueOf(invokedUri.getQueryParameter("rating")));
                ARActivity.this.startActivity(poiDetailIntent);

                Log.d("IMAGE", String.valueOf(invokedUri.getQueryParameter("image")));

                return true;
            }

            // pressed snapshot button. check if host is button to fetch e.g. 'architectsdk://button?action=captureScreen', you may add more checks if more buttons are used inside AR scene
            else if ("button".equalsIgnoreCase(invokedUri.getHost())) {
                ARActivity.this.architectView.captureScreen(
                        ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW,
                        new ArchitectView.CaptureScreenCallback() {

                            @Override
                            public void onScreenCaptured(final Bitmap screenCapture) {
                                if (ContextCompat.checkSelfPermission(ARActivity.this,
                                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                                    ARActivity.this.screenCapture = screenCapture;
                                    ActivityCompat.requestPermissions(ARActivity.this,
                                            new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                                            WIKITUDE_PERMISSIONS_REQUEST_EXTERNAL_STORAGE);
                                } else {
                                    ARActivity.this.saveScreenCaptureToExternalStorage(screenCapture);
                                }
                            }
                        });
            }
            return true;
        }
    };
}