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.denimgroup.android.training.pandemobium.stocktrader.ManageTipsActivity.java

/** Called when the activity is first created. */
@Override//from www.j a  v a 2 s  .c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.managetips);

    etSymbol = (EditText) findViewById(R.id.et_symbol);
    etTargetPrice = (EditText) findViewById(R.id.et_target_price);
    etReason = (EditText) findViewById(R.id.et_reason);

    btnSaveTip = (Button) findViewById(R.id.btn_save_tip);
    btnSaveTip.setOnClickListener(this);

    tvTipStatus = (TextView) findViewById(R.id.tv_tip_status);

    if (Intent.ACTION_MAIN.equals(getIntent().getAction())) {
        Log.d("ManageTipsActivity", "Action launched manually");
    } else {
        Uri data = getIntent().getData();

        if (data == null) {
            Log.i("ManageTipsActivity", "No data passed with intent");
        } else {
            Uri tradeUri = getIntent().getData();
            Log.i("ManageTipsActivity", "Intent launched with data: " + tradeUri.toString());
            String symbol = tradeUri.getQueryParameter("symbol").toUpperCase();

            // test ...
            //String target_price = tradeUri.getQueryParameter("target_price");

            doSendTipData(symbol);

        }
    }
}

From source file:org.getlantern.firetweet.activity.support.GoogleMapViewerActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Uri uri = getIntent().getData();
    if (uri == null || !AUTHORITY_MAP.equals(uri.getAuthority())) {
        finish();//from   w ww .  j  av a 2  s .  c om
        return;
    }
    final Bundle bundle = new Bundle();
    final double latitude = ParseUtils.parseDouble(uri.getQueryParameter(QUERY_PARAM_LAT), Double.NaN);
    final double longitude = ParseUtils.parseDouble(uri.getQueryParameter(QUERY_PARAM_LNG), Double.NaN);
    if (Double.isNaN(latitude) || Double.isNaN(longitude)) {
        finish();
        return;
    }
    try {
        bundle.putDouble(EXTRA_LATITUDE, latitude);
        bundle.putDouble(EXTRA_LONGITUDE, longitude);
    } catch (final NumberFormatException e) {
        finish();
        return;
    }
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    final Fragment fragment = isNativeMapSupported() ? new GoogleMapFragment() : new WebMapFragment();
    fragment.setArguments(bundle);
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(android.R.id.content, fragment).commit();
}

From source file:org.apache.cordova.CordovaPlugin.java

/**
 * Refer to remapUri()/*from   ww  w. j a  v a2  s.  c  om*/
 * Added in cordova-android@4.0.0
 */
protected Uri fromPluginUri(Uri pluginUri) {
    return Uri.parse(pluginUri.getQueryParameter("origUri"));
}

From source file:com.deliciousdroid.fragment.MainSearchResultsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    base = (FragmentBaseActivity) getActivity();
    base.setTitle(R.string.main_search_results_title);

    String[] MENU_ITEMS = new String[] { getString(R.string.search_results_bookmark),
            getString(R.string.search_results_tag), getString(R.string.search_results_global_tag) };

    setListAdapter(new ArrayAdapter<String>(base, R.layout.main_view, MENU_ITEMS));

    final Intent intent = base.getIntent();

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        if (intent.hasExtra(SearchManager.QUERY)) {
            Intent i = new Intent(base, MainSearchResultsFragment.class);
            i.putExtras(intent.getExtras());
            startActivity(i);/*  w  ww  . j av a 2 s.  c o  m*/
            base.finish();
        } else {
            base.onSearchRequested();
        }
    } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {

        Uri data = intent.getData();
        String path = null;
        String tagname = null;

        if (data != null) {
            path = data.getPath();
            tagname = data.getQueryParameter("tagname");
        }

        if (data.getScheme() == null || !data.getScheme().equals("content")) {
            Intent i = new Intent(Intent.ACTION_VIEW, data);

            startActivity(i);
            base.finish();
        } else if (path.contains("bookmarks") && TextUtils.isDigitsOnly(data.getLastPathSegment())) {
            Intent viewBookmark = new Intent(base, ViewBookmark.class);
            viewBookmark.setData(data);

            Log.d("View Bookmark Uri", data.toString());
            startActivity(viewBookmark);
            base.finish();
        } else if (tagname != null) {
            Intent viewTags = new Intent(base, BrowseBookmarks.class);
            viewTags.setData(data);

            Log.d("View Tags Uri", data.toString());
            startActivity(viewTags);
            base.finish();
        }
    }

    ListView lv = getListView();
    lv.setTextFilterEnabled(true);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0) {
                searchActionListener.onBookmarkSearch();
            } else if (position == 1) {
                searchActionListener.onTagSearch();
            } else if (position == 2) {
                searchActionListener.onGlobalTagSearch();
            }
        }
    });
}

From source file:org.getlantern.firetweet.activity.support.OpenStreetMapViewerActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Uri uri = getIntent().getData();
    if (uri == null || !AUTHORITY_MAP.equals(uri.getAuthority())) {
        finish();//from  w w w. j ava2  s . c o m
        return;
    }
    final double latitude = ParseUtils.parseDouble(uri.getQueryParameter(QUERY_PARAM_LAT), Double.NaN);
    final double longitude = ParseUtils.parseDouble(uri.getQueryParameter(QUERY_PARAM_LNG), Double.NaN);
    if (Double.isNaN(latitude) || Double.isNaN(longitude)) {
        finish();
        return;
    }
    mLatitude = latitude;
    mLongitude = longitude;
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    setContentView(R.layout.activity_osm_viewer);
    mMapView.setMultiTouchControls(true);
    mMapView.setBuiltInZoomControls(true);
    mMapView.setTilesScaledToDpi(true);
    final List<Overlay> overlays = mMapView.getOverlays();
    final GeoPoint gp = new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6));
    final Drawable d = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_map_marker, null);
    final Itemization markers = new Itemization(d, mMapView.getResourceProxy());
    final OverlayItem overlayitem = new OverlayItem("", "", gp);
    markers.addOverlay(overlayitem);
    overlays.add(markers);
    final IMapController mc = mMapView.getController();
    mc.setZoom(12);
    mc.setCenter(gp);
}

From source file:com.nextgis.firereporter.ScanexHttpLogin.java

@Override
protected Void doInBackground(String... urls) {
    if (HttpGetter.IsNetworkAvailible(mContext)) {
        String sUser = urls[0];//from   ww  w  .j  av  a2  s  .c o  m
        String sPass = urls[1];

        try {

            // Create a new HttpClient
            HttpClient httpclient = new DefaultHttpClient();

            // step 1. open login dialog
            String sRedirect = "http://fires.kosmosnimki.ru/SAPI/oAuthCallback.html&authServer=MyKosmosnimki";
            String sURL = "http://fires.kosmosnimki.ru/SAPI/LoginDialog.ashx?redirect_uri="
                    + Uri.encode(sRedirect);
            HttpGet httpget = new HttpGet(sURL);
            HttpParams params = httpget.getParams();
            params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
            httpget.setParams(params);
            HttpResponse response = httpclient.execute(httpget);

            //2 get cookie and params            
            Header head = response.getFirstHeader("Set-Cookie");
            String sCookie = head.getValue();

            head = response.getFirstHeader("Location");
            String sLoc = head.getValue();

            Uri uri = Uri.parse(sLoc);
            String sClientId = uri.getQueryParameter("client_id");
            String sScope = uri.getQueryParameter("scope");
            String sState = uri.getQueryParameter("state");

            String sPostUri = "http://my.kosmosnimki.ru/Account/LoginDialog?redirect_uri="
                    + Uri.encode(sRedirect) + "&client_id=" + sClientId + "&scope=" + sScope + "&state="
                    + sState;

            HttpPost httppost = new HttpPost(sPostUri);

            params = httppost.getParams();
            params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
            httppost.setHeader("Cookie", sCookie);

            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("email", sUser));
            nameValuePairs.add(new BasicNameValuePair("password", sPass));
            nameValuePairs.add(new BasicNameValuePair("IsApproved", "true"));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            response = httpclient.execute(httppost);
            head = response.getFirstHeader("Set-Cookie");

            if (head == null) {
                mError = mContext.getString(R.string.noNetwork);
                return null;
            }

            sCookie += "; " + head.getValue();
            head = response.getFirstHeader("Location");
            sLoc = head.getValue();

            uri = Uri.parse(sLoc);
            String sCode = uri.getQueryParameter("code");
            sState = uri.getQueryParameter("state");

            //3 get 
            String sGetUri = "http://fires.kosmosnimki.ru/SAPI/Account/logon/?authServer=MyKosmosnimki&code="
                    + sCode + "&state=" + sState;
            httpget = new HttpGet(sGetUri);
            httpget.setHeader("Cookie", sCookie);
            params = httpget.getParams();
            params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
            httpget.setParams(params);
            response = httpclient.execute(httpget);

            head = response.getFirstHeader("Set-Cookie");
            if (head == null) {
                mError = mContext.getString(R.string.noNetwork);
                return null;
            }
            sCookie += "; " + head.getValue();

            Bundle bundle = new Bundle();
            if (sCookie.length() > 0) {
                //if(bGetCookie){
                bundle.putBoolean(GetFiresService.ERROR, false);
                bundle.putString(GetFiresService.JSON, sCookie);
                //bundle.putString("json", mContent);
            } else {
                bundle.putBoolean(GetFiresService.ERROR, true);
            }

            bundle.putInt(GetFiresService.SOURCE, mnType);
            Message msg = new Message();
            msg.setData(bundle);
            if (mEventReceiver != null) {
                mEventReceiver.sendMessage(msg);
            }

        } catch (ClientProtocolException e) {
            mError = e.getMessage();
            return null;
        } catch (IOException e) {
            mError = e.getMessage();
            return null;
        } catch (Exception e) {
            mError = e.getMessage();
            return null;
        }
    } else {
        Bundle bundle = new Bundle();
        bundle.putBoolean(GetFiresService.ERROR, true);
        bundle.putString(GetFiresService.ERR_MSG, mContext.getString(R.string.noNetwork));
        bundle.putInt(GetFiresService.SOURCE, mnType);

        Message msg = new Message();
        msg.setData(bundle);
        if (mEventReceiver != null) {
            mEventReceiver.sendMessage(msg);
        }
    }
    return null;
}

From source file:com.zoterodroid.activity.BrowseCitations.java

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

    mAccountManager = AccountManager.get(this);
    mAccount = mAccountManager.getAccountsByType(Constants.ACCOUNT_TYPE)[0];
    mContext = this;

    Log.d("browse bookmarks", getIntent().getDataString());
    Uri data = getIntent().getData();
    String scheme = data.getScheme();
    String path = data.getPath();
    Log.d("path", path);
    String username = data.getQueryParameter("username");
    String tagname = data.getQueryParameter("tagname");
    String recent = data.getQueryParameter("recent");

    myself = mAccount.name.equals(username);

    ArrayList<Citation> citationList = new ArrayList<Citation>();

    if (scheme.equals("content") && path.equals("/citations") && myself) {

        try {/*from   w  ww.  j  a  v a2s  .c  o m*/

            String[] projection = new String[] { Citation._ID, Citation.Title, Citation.Key,
                    Citation.Creator_Summary, Citation.Item_Type };
            String selection = null;
            String sortorder = null;

            selection = Citation.Account + " = '" + username + "'";

            Uri citations = Citation.CONTENT_URI;

            Cursor c = managedQuery(citations, projection, selection, null, sortorder);

            if (c.moveToFirst()) {
                int idColumn = c.getColumnIndex(Citation._ID);
                int titleColumn = c.getColumnIndex(Citation.Title);
                int keyColumn = c.getColumnIndex(Citation.Key);
                int creatorSummaryColumn = c.getColumnIndex(Citation.Creator_Summary);
                int itemTypeColumn = c.getColumnIndex(Citation.Item_Type);

                do {

                    Citation b = new Citation(c.getInt(idColumn), c.getString(titleColumn),
                            c.getString(keyColumn), c.getString(creatorSummaryColumn),
                            c.getString(itemTypeColumn));

                    citationList.add(b);

                } while (c.moveToNext());

            }

            setListAdapter(new CitationListAdapter(this, R.layout.bookmark_view, citationList));
        } catch (Exception e) {
        }

    }

    lv = getListView();
    lv.setTextFilterEnabled(true);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        }
    });

    /* Add Context-Menu listener to the ListView. */
    lv.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            menu.setHeaderTitle("Actions");
            if (myself) {
                menu.add(Menu.NONE, 0, Menu.NONE, "Delete");
            } else {
                menu.add(Menu.NONE, 1, Menu.NONE, "Add");
            }

        }
    });
}

From source file:mobisocial.musubi.objects.WebAppObj.java

String getAppName(Obj obj) {
    Uri appUri = Uri.parse(obj.getJson().optString(OBJ_URL));
    String given = appUri.getQueryParameter("n");
    if (given == null) {
        given = appUri.getLastPathSegment();
        if (given == null || given.length() <= 1 || given.startsWith("index")) {
            List<String> segs = appUri.getPathSegments();
            if (segs.size() > 1) {
                given = segs.get(segs.size() - 2);
            } else {
                given = appUri.getAuthority();
            }// w w w .  j  a v  a 2s.  com
        }
    }
    return given;
}

From source file:com.simonmacdonald.corinthian.VideoPlayer.java

private void playVideo(String url) throws IOException {
    // Create URI
    Uri uri = Uri.parse(url);

    Intent intent = null;/*ww  w  .  jav a2 s . c o  m*/
    // Check to see if someone is trying to play a YouTube page.
    if (url.contains(YOU_TUBE)) {
        // If we don't do it this way you don't have the option for youtube
        uri = Uri.parse("vnd.youtube:" + uri.getQueryParameter("v"));
        intent = new Intent(Intent.ACTION_VIEW, uri);
    } else if (url.contains(ASSETS)) {
        // get file path in assets folder
        String filepath = url.replace(ASSETS, "");
        // get actual filename from path as command to write to internal storage doesn't like folders
        String filename = filepath.substring(filepath.lastIndexOf("/") + 1, filepath.length());

        // Don't copy the file if it already exists
        File fp = new File(this.cordova.getContext().getFilesDir() + "/" + filename);
        if (!fp.exists()) {
            this.copy(filepath, filename);
        }

        // change uri to be to the new file in internal storage
        uri = Uri.parse("file://" + this.cordova.getContext().getFilesDir() + "/" + filename);

        // Display video player
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "video/*");
    } else {
        // Display video player
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "video/*");
    }

    this.cordova.getActivity().startActivity(intent);
}

From source file:com.facebook.samples.rps.MainActivity.java

private int getAppLinkGesture(Intent intent) {
    Uri targetURI = AppLinks.getTargetUrlFromInboundIntent(this, intent);
    if (targetURI == null) {
        return INVALID_CHOICE;
    }/*from   w  w  w  . j  a v a  2  s.c o  m*/
    String gesture = targetURI.getQueryParameter("gesture");
    if (gesture != null && gesture.equalsIgnoreCase(getString(R.string.rock))) {
        return RpsGameUtils.ROCK;
    } else if (gesture.equalsIgnoreCase(getString(R.string.paper))) {
        return RpsGameUtils.PAPER;
    } else if (gesture.equalsIgnoreCase(getString(R.string.scissors))) {
        return RpsGameUtils.SCISSORS;
    }
    return INVALID_CHOICE;
}