Example usage for android.net Uri toString

List of usage examples for android.net Uri toString

Introduction

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

Prototype

public abstract String toString();

Source Link

Document

Returns the encoded string representation of this URI.

Usage

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);//from   w ww .j a v  a 2  s  .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.hybris.mobile.lib.commerce.provider.CatalogProvider.java

/**
 * Insert the new item or update it if already in database
 *
 * @param uri    String of characters used to identify a name of a resource
 * @param values Set of content values/*from   w w w  .  j a v a 2s  . c om*/
 */
private void insertOrUpdate(Uri uri, ContentValues values) {

    switch (URI_MATCHER.match(uri)) {
    // Insert or Update a data
    case CatalogContract.Provider.CODE_DATA_ID:
        insertOrUpdateGeneric(uri, values, CatalogContract.DataBaseData.ATT_DATA_ID,
                CatalogContract.DataBaseDataSimple.TABLE_NAME);
        break;

    // Insert or Update a data details
    case CatalogContract.Provider.CODE_DATA_DETAILS_ID:
        insertOrUpdateGeneric(uri, values, CatalogContract.DataBaseData.ATT_DATA_ID,
                CatalogContract.DataBaseDataDetails.TABLE_NAME);
        break;

    // Insert or Update a group sync status
    case CatalogContract.Provider.CODE_SYNC_GROUP:
        insertOrUpdateGeneric(uri, values, CatalogContract.DataBaseSyncStatusGroup.ATT_GROUP_ID,
                CatalogContract.DataBaseSyncStatusGroup.TABLE_NAME);
        break;

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

}

From source file:com.remobile.camera.CameraLauncher.java

/**
 * Applies all needed transformation to the image received from the gallery.
 *
 * @param destType In which form should we return the image
 * @param intent   An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
 */// w  w w  . j ava  2 s.c  o  m
private void processResultFromGallery(int destType, Intent intent) {
    Uri uri = intent.getData();
    if (uri == null) {
        if (croppedUri != null) {
            uri = croppedUri;
        } else {
            this.failPicture("null data from photo library");
            return;
        }
    }
    int rotate = 0;

    // If you ask for video or all media type you will automatically get back a file URI
    // and there will be no attempt to resize any returned data
    if (this.mediaType != PICTURE) {
        this.callbackContext.success(uri.toString());
    } else {
        // This is a special case to just return the path as no scaling,
        // rotating, nor compressing needs to be done
        if (this.targetHeight == -1 && this.targetWidth == -1
                && (destType == FILE_URI || destType == NATIVE_URI) && !this.correctOrientation) {
            this.callbackContext.success(uri.toString());
        } else {
            String uriString = uri.toString();
            // Get the path to the image. Makes loading so much easier.
            String mimeType = FileHelper.getMimeType(uriString, this.cordova);
            // If we don't have a valid image so quit.
            if (!("image/jpeg".equalsIgnoreCase(mimeType) || "image/png".equalsIgnoreCase(mimeType))) {
                Log.d(LOG_TAG, "I either have a null image path or bitmap");
                this.failPicture("Unable to retrieve path to picture!");
                return;
            }
            Bitmap bitmap = null;
            try {
                bitmap = getScaledBitmap(uriString);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (bitmap == null) {
                Log.d(LOG_TAG, "I either have a null image path or bitmap");
                this.failPicture("Unable to create bitmap!");
                return;
            }

            if (this.correctOrientation) {
                rotate = getImageOrientation(uri);
                if (rotate != 0) {
                    Matrix matrix = new Matrix();
                    matrix.setRotate(rotate);
                    try {
                        bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(),
                                matrix, true);
                        this.orientationCorrected = true;
                    } catch (OutOfMemoryError oom) {
                        this.orientationCorrected = false;
                    }
                }
            }

            // If sending base64 image back
            if (destType == DATA_URL) {
                this.processPicture(bitmap);
            }

            // If sending filename back
            else if (destType == FILE_URI || destType == NATIVE_URI) {
                // Did we modify the image?
                if ((this.targetHeight > 0 && this.targetWidth > 0)
                        || (this.correctOrientation && this.orientationCorrected)) {
                    try {
                        String modifiedPath = this.ouputModifiedBitmap(bitmap, uri);
                        // The modified image is cached by the app in order to get around this and not have to delete you
                        // application cache I'm adding the current system time to the end of the file url.
                        this.callbackContext
                                .success("file://" + modifiedPath + "?" + System.currentTimeMillis());
                    } catch (Exception e) {
                        e.printStackTrace();
                        this.failPicture("Error retrieving image.");
                    }
                } else {
                    this.callbackContext.success(uri.toString());
                }
            }
            if (bitmap != null) {
                bitmap.recycle();
                bitmap = null;
            }
            System.gc();
        }
    }
}

From source file:com.cranberrygame.cordova.plugin.game.Util.java

private void _getPlayerImage() {
    Player player = Games.Players.getCurrentPlayer(getGameHelper().getApiClient());
    if (player != null) {
        boolean hasH = player.hasHiResImage();
        boolean hasI = player.hasIconImage();
        Uri playerImageUrl = null;
        if (hasH) {
            playerImageUrl = player.getHiResImageUri();
        } else if (hasI) {
            playerImageUrl = player.getIconImageUri();
        } else {//from w  w w  .  ja  v  a 2s .c om
            //PluginResult pr = new PluginResult(PluginResult.Status.OK);
            //pr.setKeepCallback(true);
            //getPlayerImageCC.sendPluginResult(pr);
            PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
            //pr.setKeepCallback(true);
            getPlayerImageCC.sendPluginResult(pr);

            return;
        }

        PluginResult pr = new PluginResult(PluginResult.Status.OK, playerImageUrl.toString());
        //pr.setKeepCallback(true);
        getPlayerImageCC.sendPluginResult(pr);
        //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
        //pr.setKeepCallback(true);
        //getPlayerImageCC.sendPluginResult(pr);         
    } else {
        //PluginResult pr = new PluginResult(PluginResult.Status.OK);
        //pr.setKeepCallback(true);
        //getPlayerImageCC.sendPluginResult(pr);
        PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
        //pr.setKeepCallback(true);
        getPlayerImageCC.sendPluginResult(pr);
    }
}

From source file:org.projecthdata.weight.service.SyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    Connection<HData> connection = connectionRepository.getPrimaryConnection(HData.class);

    this.prefs.edit().putString(Constants.PREF_SYNC_STATE, SyncState.WORKING.toString()).commit();
    //get all readings that are not synced
    try {//from w  w w.j av a 2 s. c  o m
        Dao<WeightReading, Integer> dao = ormManager.getDatabaseHelper().getWeightDao();
        //TODO: query the database instead of iterating over the whole table

        String url = this.prefs.getString(Constants.PREF_EHR_URL, "");
        Uri uri = Uri.parse(url);
        uri = uri.buildUpon().appendPath("vitalsigns").appendPath("bodyweight").build();
        RestTemplate template = connection.getApi().getRootOperations().getRestTemplate();

        HttpHeaders requestHeaders = new HttpHeaders();
        requestHeaders.setContentType(MediaType.APPLICATION_XML);

        for (WeightReading reading : dao) {

            if (!reading.isSynched()) {
                Result result = new Result();
                //date and time
                result.setResultDateTime(new DateTime(reading.getDateTime().getTime()).toString(dateFormatter));
                //narrative
                result.setNarrative(NARRATIVE);
                //result id
                result.setResultId(UUID.randomUUID().toString());
                //result type code
                result.getResultType().setCode(CODE);
                //result type code system
                result.getResultType().setCodeSystem(CODE_SYSTEM);
                //status code
                result.setResultStatusCode(RESULT_STATUS_CODE);
                //value
                result.setResultValue(reading.getResultValue().toString());
                //value unit
                result.setResultValueUnit(UNITS);

                try {

                    HttpEntity<Result> requestEntity = new HttpEntity<Result>(result, requestHeaders);
                    template.exchange(uri.toString(), HttpMethod.POST, requestEntity, String.class);
                } catch (RestClientException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                reading.setSynched(true);
                dao.update(reading);
            }
        }
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    this.prefs.edit().putString(Constants.PREF_SYNC_STATE, SyncState.READY.toString()).commit();

}

From source file:de.lespace.apprtc.activity.ConnectActivity.java

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

    // Get setting keys.
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    keyprefFrom = getString(R.string.pref_from_key);
    keyprefVideoCallEnabled = getString(R.string.pref_videocall_key);
    keyprefResolution = getString(R.string.pref_resolution_key);
    keyprefFps = getString(R.string.pref_fps_key);
    keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key);
    keyprefVideoBitrateType = getString(R.string.pref_startvideobitrate_key);
    keyprefVideoBitrateValue = getString(R.string.pref_startvideobitratevalue_key);
    keyprefVideoCodec = getString(R.string.pref_videocodec_key);
    keyprefHwCodecAcceleration = getString(R.string.pref_hwcodec_key);
    keyprefCaptureToTexture = getString(R.string.pref_capturetotexture_key);
    keyprefAudioBitrateType = getString(R.string.pref_startaudiobitrate_key);
    keyprefAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
    keyprefAudioCodec = getString(R.string.pref_audiocodec_key);
    keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key);
    keyprefAecDump = getString(R.string.pref_aecdump_key);
    keyprefOpenSLES = getString(R.string.pref_opensles_key);
    keyprefDisplayHud = getString(R.string.pref_displayhud_key);
    keyprefTracing = getString(R.string.pref_tracing_key);
    keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key);
    keyprefRoomList = getString(R.string.pref_room_list_key);

    // Video call enabled flag.
    boolean videoCallEnabled = sharedPref.getBoolean(keyprefVideoCallEnabled,
            Boolean.valueOf(getString(R.string.pref_videocall_default)));

    String wssUrl = sharedPref.getString(keyprefRoomServerUrl,
            getString(R.string.pref_room_server_url_default));
    from = sharedPref.getString(keyprefFrom, getString(R.string.pref_from_default));
    // Get default codecs.
    String videoCodec = sharedPref.getString(keyprefVideoCodec, getString(R.string.pref_videocodec_default));
    String audioCodec = sharedPref.getString(keyprefAudioCodec, getString(R.string.pref_audiocodec_default));

    // Check HW codec flag.
    boolean hwCodec = sharedPref.getBoolean(keyprefHwCodecAcceleration,
            Boolean.valueOf(getString(R.string.pref_hwcodec_default)));

    // Check Capture to texture.
    boolean captureToTexture = sharedPref.getBoolean(keyprefCaptureToTexture,
            Boolean.valueOf(getString(R.string.pref_capturetotexture_default)));

    // Check Disable Audio Processing flag.
    boolean noAudioProcessing = sharedPref.getBoolean(keyprefNoAudioProcessingPipeline,
            Boolean.valueOf(getString(R.string.pref_noaudioprocessing_default)));

    // Check Disable Audio Processing flag.
    boolean aecDump = sharedPref.getBoolean(keyprefAecDump,
            Boolean.valueOf(getString(R.string.pref_aecdump_default)));

    // Check OpenSL ES enabled flag.
    boolean useOpenSLES = sharedPref.getBoolean(keyprefOpenSLES,
            Boolean.valueOf(getString(R.string.pref_opensles_default)));

    // Check for mandatory permissions.
    missingPermissions = new ArrayList();

    for (String permission : MANDATORY_PERMISSIONS) {
        if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
            missingPermissions.add(permission);
        }/*from ww  w . ja v a2  s .  com*/
    }
    requestPermission();

    networkchangeBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {

            if (intent.getFlags() == 0) {
                SignalingService.appRTCClient.resetWebsocket();
            }
            if (intent.getFlags() == 1) {
                SignalingService.appRTCClient.reconnect();
                Toast.makeText(context, "network is online:" + intent.getFlags(), Toast.LENGTH_LONG).show();
            }
        }
    };

    // Registering BroadcastReceiver
    registerNetworkChangeReceiver();

    // Get video resolution from settings.
    int videoWidth = 0;
    int videoHeight = 0;
    String resolution = sharedPref.getString(keyprefResolution, getString(R.string.pref_resolution_default));
    String[] dimensions = resolution.split("[ x]+");
    if (dimensions.length == 2) {
        try {
            videoWidth = Integer.parseInt(dimensions[0]);
            videoHeight = Integer.parseInt(dimensions[1]);
        } catch (NumberFormatException e) {
            videoWidth = 0;
            videoHeight = 0;
            Log.e(TAG, "Wrong video resolution setting: " + resolution);
        }
    }

    // Get camera fps from settings.
    int cameraFps = 0;
    String fps = sharedPref.getString(keyprefFps, getString(R.string.pref_fps_default));
    String[] fpsValues = fps.split("[ x]+");
    if (fpsValues.length == 2) {
        try {
            cameraFps = Integer.parseInt(fpsValues[0]);
        } catch (NumberFormatException e) {
            Log.e(TAG, "Wrong camera fps setting: " + fps);
        }
    }

    // Check capture quality slider flag.
    boolean captureQualitySlider = sharedPref.getBoolean(keyprefCaptureQualitySlider,
            Boolean.valueOf(getString(R.string.pref_capturequalityslider_default)));

    // Get video and audio start bitrate.
    int videoStartBitrate = 0;
    String bitrateTypeDefault = getString(R.string.pref_startvideobitrate_default);
    String bitrateType = sharedPref.getString(keyprefVideoBitrateType, bitrateTypeDefault);
    if (!bitrateType.equals(bitrateTypeDefault)) {
        String bitrateValue = sharedPref.getString(keyprefVideoBitrateValue,
                getString(R.string.pref_startvideobitratevalue_default));
        videoStartBitrate = Integer.parseInt(bitrateValue);
    }
    int audioStartBitrate = 0;
    bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_default);
    bitrateType = sharedPref.getString(keyprefAudioBitrateType, bitrateTypeDefault);
    if (!bitrateType.equals(bitrateTypeDefault)) {
        String bitrateValue = sharedPref.getString(keyprefAudioBitrateValue,
                getString(R.string.pref_startaudiobitratevalue_default));
        audioStartBitrate = Integer.parseInt(bitrateValue);
    }

    // Check statistics display option.
    boolean displayHud = sharedPref.getBoolean(keyprefDisplayHud,
            Boolean.valueOf(getString(R.string.pref_displayhud_default)));

    boolean tracing = sharedPref.getBoolean(keyprefTracing,
            Boolean.valueOf(getString(R.string.pref_tracing_default)));

    // Log.d(TAG, "Connecting from " + from + " at URL " + wssUrl);

    if (validateUrl(wssUrl)) {
        Uri uri = Uri.parse(wssUrl);
        intent = new Intent(this, ConnectActivity.class);
        intent.setData(uri);
        intent.putExtra(CallActivity.EXTRA_VIDEO_CALL, videoCallEnabled);
        intent.putExtra(CallActivity.EXTRA_VIDEO_WIDTH, videoWidth);
        intent.putExtra(CallActivity.EXTRA_VIDEO_HEIGHT, videoHeight);
        intent.putExtra(CallActivity.EXTRA_VIDEO_FPS, cameraFps);
        intent.putExtra(CallActivity.EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABLED, captureQualitySlider);
        intent.putExtra(CallActivity.EXTRA_VIDEO_BITRATE, videoStartBitrate);
        intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, videoCodec);
        intent.putExtra(CallActivity.EXTRA_HWCODEC_ENABLED, hwCodec);
        intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, captureToTexture);
        intent.putExtra(CallActivity.EXTRA_NOAUDIOPROCESSING_ENABLED, noAudioProcessing);
        intent.putExtra(CallActivity.EXTRA_AECDUMP_ENABLED, aecDump);
        intent.putExtra(CallActivity.EXTRA_OPENSLES_ENABLED, useOpenSLES);
        intent.putExtra(CallActivity.EXTRA_AUDIO_BITRATE, audioStartBitrate);
        intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, audioCodec);
        intent.putExtra(CallActivity.EXTRA_DISPLAY_HUD, displayHud);
        intent.putExtra(CallActivity.EXTRA_TRACING, tracing);
        intent.putExtra(CallActivity.EXTRA_RUNTIME, runTimeMs);
    }

    roomListView = (ListView) findViewById(R.id.room_listview);
    roomListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    connectButton = (ImageButton) findViewById(R.id.connect_button);
    connectButton.setOnClickListener(connectListener);

    // If an implicit VIEW intent is launching the app, go directly to that URL.
    //final Intent intent = getIntent();
    Uri wsurl = Uri.parse(wssUrl);
    //intent.getData();
    // Log.d(TAG, "connecting to:" + wsurl.toString());
    if (wsurl == null) {
        logAndToast(getString(R.string.missing_wsurl));
        Log.e(TAG, "Didn't get any URL in intent!");
        setResult(RESULT_CANCELED);
        finish();
        return;
    }

    if (from == null || from.length() == 0) {
        logAndToast(getString(R.string.missing_from));
        Log.e(TAG, "Incorrect from in intent!");
        setResult(RESULT_CANCELED);
        finish();
        return;
    }

    peerConnectionParameters = new PeerConnectionClient.PeerConnectionParameters(videoCallEnabled, tracing,
            videoWidth, videoHeight, cameraFps, videoStartBitrate, videoCodec, hwCodec, captureToTexture,
            audioStartBitrate, audioCodec, noAudioProcessing, aecDump, useOpenSLES);

    Intent intent = getIntent();
    Log.i(TAG, "created apprtc with uri:" + wsurl.toString() + " from:" + from);

    Log.i(TAG, "intent.EXTRA_TO:" + intent.getStringExtra(RTCConnection.EXTRA_TO));
    Log.i(TAG, "intent.EXTRA_FROM:" + intent.getStringExtra(RTCConnection.EXTRA_FROM));
    Log.i(TAG, "intent.EXTRA_INITIATOR:" + intent.getBooleanExtra(RTCConnection.EXTRA_INITIATOR, false));

    if (intent.getStringExtra(RTCConnection.EXTRA_TO) != null
            && !intent.getStringExtra(RTCConnection.EXTRA_TO).equals("")) {

        RTCConnection.to = intent.getStringExtra(RTCConnection.EXTRA_TO);
        RTCConnection.from = intent.getStringExtra(RTCConnection.EXTRA_FROM);
        RTCConnection.initiator = intent.getBooleanExtra(RTCConnection.EXTRA_INITIATOR, false);
        ;
        connectToUser();
    }

    /*  if(intent.getStringExtra(RTCConnection.EXTRA_TO)!=null
            && !intent.getStringExtra(RTCConnection.EXTRA_TO).equals("")){
            
          RTCConnection.to = intent.getStringExtra(RTCConnection.EXTRA_TO);
         // RTCConnection.from = intent.getStringExtra(RTCConnection.EXTRA_FROM);
          RTCConnection.initiator = intent.getBooleanExtra(RTCConnection.EXTRA_INITIATOR,false);;
            
      Intent serviceIntent = new Intent(this,SignalingService.class);
      serviceIntent.putExtra(RTCConnection.EXTRA_FROM, RTCConnection.to);
            
     //WebRTC-Signaling
     startService(intent);
    }*/

}

From source file:com.hackensack.umc.activity.ProfileSelfiewithCropActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (selectedImageView == Constant.INSU_PROOF_FRONT || selectedImageView == Constant.INSU_PROOF_BACK
            || selectedImageView == Constant.ID_PROOF_FRONT || selectedImageView == Constant.ID_PROOF_BACK) {
        Fragment fragment = (Fragment) getSupportFragmentManager().findFragmentByTag("IsuranceFragment");
        if (fragment != null) {
            fragment.onActivityResult(requestCode, resultCode, data);
            return;
        }//from   w w w  .j  a v a 2  s. c om
    }
    switch (requestCode) {
    case Constant.FRAGMENT_CONST_REQUEST_IMAGE_CAPTURE:
        if (resultCode == RESULT_OK) {
            /*Intent intent = new Intent(ProfileSelfieActivity.this, ActivityCropImage.class);
            intent.setData(imageUri);
            startActivityForResult(intent, Constant.CROP_IMAGE_ACTIVITY);*/

            //cropPictureIntent(imageUri);
            doCrop(imageUri);
        }
        break;
    /* case 123:
        if (data != null) {
          //  Bundle extras = data.getExtras();
            //if (extras != null) {
              //  imageUri =data.getData();
            imgSelfie.setImageBitmap(CameraFunctionality.getBitmapFromFile(imageUri.toString(), ProfileSelfiewithCropActivity.this));
            //  saveImage(photo);
            //}
        }*/
    //  break;
    case 123:
        if (resultCode == RESULT_OK) {
            try {
                if (data != null) {
                    if (selectedImageView == Constant.SELFIE) {
                        /*Uri imageUriFromIntent = data.getData();
                        if (imageUriFromIntent == null) {
                            imageUriFromIntent = data.getExtras().getParcelable("data");
                        }
                                
                        //  if(imageUriFromIntent==null){*/
                        Uri imageUriFromIntent = imageUri;
                        //}

                        /*CameraFunctionality.setPhotoToImageView(imageUri.toString(), imgSelfie, ProfileSelfieActivity.this);
                        byte[] byteArray = getIntent().getByteArrayExtra(Constant.BITMAP_IMAGE);
                        Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
                        getImageUris(imageUri, 5,bmp,null);*/

                        Bitmap bitmapImage = data.getExtras().getParcelable("data");

                        if (bitmapImage == null) {
                            bitmapImage = CameraFunctionality.getBitmapFromFile(imageUriFromIntent.toString(),
                                    ProfileSelfiewithCropActivity.this);
                        }
                        String base64 = Base64Converter.createBase64StringFromBitmapNew(bitmapImage,
                                ProfileSelfiewithCropActivity.this);
                        getImageUris(imageUriFromIntent, selectedImageView, null, base64);

                        //CameraFunctionality.setPhotoToImageView(imageUri.toString(), imgIcFront, getActivity());
                        //

                        CameraFunctionality.setBitMapToImageView(imageUriFromIntent.toString(), bitmapImage,
                                imgSelfie, ProfileSelfiewithCropActivity.this);
                        /*ImageLoader imageLoader=new ImageLoader(ProfileSelfiewithCropActivity.this);
                        imageLoader.displayImage(imageUriFromIntent.toString(),imgSelfie);*/
                        // bitmapImage.recycle();

                        //pathSelfie = imageUri;

                        /*   Bitmap bitmapImage = CameraFunctionality.unCompressedImage(data.getByteArrayExtra(Constant.BITMAP_IMAGE));
                                
                           pathSelfie=Base64Converter.createBase64StringFroImage(bitmapImage,ProfileSelfieActivity.this);*/

                        txtSefileSet.setText(R.string.done);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        break;
    }
}

From source file:com.phonegap.plugins.wsiCameraLauncher.WsiCameraLauncher.java

private String getRealPathFromURI(Uri contentUri, CordovaInterface cordova) {
    final String scheme = contentUri.getScheme();

    if (scheme.compareTo("content") == 0) {
        String[] proj = { "_data" };
        Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null, null);
        int column_index = cursor.getColumnIndexOrThrow("_data");
        cursor.moveToFirst();// w w w.jav a 2s .c  om
        return cursor.getString(column_index);
    } else if (scheme.compareTo("file") == 0) {
        return contentUri.getPath();
    } else {
        return contentUri.toString();
    }
}

From source file:com.BeatYourRecord.SubmitActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    boolean haveConnectedWifi = false;
    boolean haveConnectedMobile = false;
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo[] netInfo = cm.getAllNetworkInfo();
    for (NetworkInfo ni : netInfo) {
        if (ni.getTypeName().equalsIgnoreCase("WIFI"))
            if (ni.isConnected())
                haveConnectedWifi = true;
        if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
            if (ni.isConnected())
                haveConnectedMobile = true;
    }/*from w w  w .  j  av  a2  s .c om*/
    if (haveConnectedWifi == false) {
        showDialog(11);
    }
    super.onCreate(savedInstanceState);

    // SharedPreferences pref = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode
    //Editor editor = pref.edit();
    //auth = pref.getString("BYR_session", null);
    /*SharedPreferences pref6 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode
      Editor editor7 = pref6.edit();
      //this.setContentView(R.layout.submit);
        String logoutme = pref6.getString("log", null);
        //log.v("log",logoutme);
     */
    SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode
    Editor editor1 = pref1.edit();
    tourid = pref1.getString("id", null);
    logout = pref1.getString("log", null);
    filepath = pref1.getString("filepath", null);
    //log.v("id",tourid);
    //log.v("log",logout);

    Log.v("reached here first", "reached here first");
    File f = new File("/data/data/com.BeatYourRecord/shared_prefs/Tester15.xml");
    if (f.exists() && logout.equals("yes") == false) {

        //log.v("yyy","yyy");
        SharedPreferences pref = SubmitActivity.this.getSharedPreferences("Tester15", 0); // 0 - for private mode
        Editor editor = pref.edit();
        this.setContentView(R.layout.submit);
        auth = pref.getString("BYR_session", null);

    } else {
        //log.v("yyy","yyy1");
        this.setContentView(R.layout.submit1);
        showDialog(10);
    }

    //   String checksession = pref.getString("BYR_session", null);
    //   //log.v("checksession", checksession);

    ////log.v("Authhere",auth);
    this.authorizer = new ClientLoginAuthorizer.ClientLoginAuthorizerFactory().getAuthorizer(this,
            ClientLoginAuthorizer.YOUTUBE_AUTH_TOKEN_TYPE);

    dbHelper = new DbHelper(this);
    dbHelper = dbHelper.open();

    Intent intent = this.getIntent();
    this.videoUri = intent.getData();
    SharedPreferences pref1223 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode
    Editor editor1223 = pref1223.edit();
    filepath = pref1223.getString("filepath", null);
    // this.videoUri =

    //   Uri path = Uri.parse(filepath);
    //File f1 = new File(filepath);  
    //Uri imageUri = Uri.fromFile(f1);
    //this.videoUri = imageUri;
    //this.videoUri = path;

    Log.v("Reached here second", "Reached here secord");
    //this.videoUri= Uri.fromFile(new File("/sdcard/Movies/com.BeatYourRecord/BYR_tournName_dateTim_20130724181901222.mp4"));
    //log.v("haha","haha");

    MediaScannerConnectionClient mediaScannerClient = new MediaScannerConnectionClient() {
        private MediaScannerConnection msc = null;
        {
            msc = new MediaScannerConnection(getApplicationContext(), this);
            msc.connect();
        }

        public void onMediaScannerConnected() {
            msc.scanFile(filepath, null);
        }

        public void onScanCompleted(String path, Uri uri) {
            //This is where you get your content uri
            Log.d("test3", uri.toString());
            needed = uri;
            // videoUri=needed;

            msc.disconnect();
        }
    };

    String videoPath = "";

    try {
        videoPath = getFilePathFromUri(this.videoUri);
        filepath1 = videoPath;
        Log.v("videoPath", videoPath);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    File videoFile = new File(videoPath);

    this.ytdDomain = intent.getExtras().getString(DbHelper.YTD_DOMAIN);
    this.assignmentId = intent.getExtras().getString(DbHelper.ASSIGNMENT_ID);

    this.domainHeader = (TextView) this.findViewById(R.id.domainHeader);
    domainHeader.setText(SettingActivity.getYtdDomains(this).get(this.ytdDomain));

    this.preferences = this.getSharedPreferences(MainActivity.SHARED_PREF_NAME, Activity.MODE_PRIVATE);
    this.youTubeName = preferences.getString(DbHelper.YT_ACCOUNT, null);

    final Button submitButton = (Button) findViewById(R.id.submitButton);
    submitButton.setEnabled(false);

    submitButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_LEGAL);
        }
    });
    addusertotournament();
    Button cancelButton = (Button) findViewById(R.id.cancelButton);
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            //SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode
            //Editor editor = pref1.edit();
            //editor.putString("filepath", permfilepath); 
            //editor.commit();
            Intent intent = new Intent(SubmitActivity.this, DetailsActivity.class);
            //    intent.putExtra(DbHelper.YTD_DOMAIN, "TODO-appname.appspot.com");

            //intent.setData(Uri.fromFile(file));   
            startActivity(intent);
            finish();
            // setResult(RESULT_CANCELED);
            //finish();
        }
    });

    Button forgotButton = (Button) findViewById(R.id.forgotButton);

    forgotButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            //SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode
            //Editor editor = pref1.edit();
            //editor.putString("filepath", permfilepath); 
            //editor.commit();

            SharedPreferences pref155 = getApplicationContext().getSharedPreferences("TourPref", 0); // 0 - for private mode
            Editor editor155 = pref155.edit();

            editor155.putString("filepath", filepath1);
            editor155.commit();
            Log.v("fielpathss", filepath1);
            Intent intent = new Intent(SubmitActivity.this, DetailsActivity.class);
            //    intent.putExtra(DbHelper.YTD_DOMAIN, "TODO-appname.appspot.com");

            //intent.setData(Uri.fromFile(file));   
            startActivity(intent);
            //   finish();
            // setResult(RESULT_CANCELED);
            //finish();
        }
    });

    EditText titleEdit = (EditText) findViewById(R.id.submitTitle);
    titleEdit.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable arg0) {
            enableSubmitIfReady();
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });
    EditText descriptionEdit = (EditText) findViewById(R.id.submitDescription);
    descriptionEdit.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable arg0) {
            enableSubmitIfReady();
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    Cursor cursor = this.managedQuery(this.videoUri, null, null, null, null);

    if (cursor.getCount() == 0) {
        Log.d(LOG_TAG, "not a valid video uri");
        Toast.makeText(SubmitActivity.this, "not a valid video uri", Toast.LENGTH_LONG).show();
    } else {
        getVideoLocation();

        if (cursor.moveToFirst()) {

            long id = cursor.getLong(cursor.getColumnIndex(Video.VideoColumns._ID));
            this.dateTaken = new Date(cursor.getLong(cursor.getColumnIndex(Video.VideoColumns.DATE_TAKEN)));
            Log.v("here", "here12");
            SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, MMM d, yyyy hh:mm aaa");
            Configuration userConfig = new Configuration();
            Settings.System.getConfiguration(getContentResolver(), userConfig);
            /* Calendar cal = Calendar.getInstance(userConfig.locale);
             TimeZone tz = cal.getTimeZone();*/
            Log.v("here", "here13");

            // dateFormat.setTimeZone(tz);

            TextView dateTakenView = (TextView) findViewById(R.id.dateCaptured);
            dateTakenView.setText("Date captured: " + dateFormat.format(dateTaken));

            ImageView thumbnail = (ImageView) findViewById(R.id.thumbnail);
            ContentResolver crThumb = getContentResolver();
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize = 1;
            Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, id,
                    MediaStore.Video.Thumbnails.MICRO_KIND, options);
            thumbnail.setImageBitmap(curThumb);
        }
    }
}

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

private void processIntent(Intent intent) {
    Uri uri = intent.getData();
    if (uri != null) {
        String url = uri.toString();

        if (RegexPatterns.FRIEND_INVITE_WITH_SECRET_URL.matcher(url).matches()) {
            popupRegisterFirst(uri);//www  .  j a va  2  s.com

            String invitorCode = url.substring(ProcessScanActivity.URL_ROGERTHAT_PREFIX.length(),
                    url.indexOf("?"));
            String secret = uri.getQueryParameter("s");
            Configuration cfg = mService.getConfigurationProvider()
                    .getConfiguration(RegistrationWizard2.CONFIGKEY);
            cfg.put(INVITOR_CODE_CONFIGKEY, invitorCode);
            cfg.put(INVITOR_SECRET_CONFIGKEY, secret);
            mService.getConfigurationProvider().updateConfigurationNow(RegistrationWizard2.CONFIGKEY, cfg);

        } else if (RegexPatterns.FRIEND_INVITE_URL.matcher(url).matches()
                || RegexPatterns.SERVICE_INTERACT_URL.matcher(url).matches()) {
            popupRegisterFirst(uri);

            Configuration cfg = mService.getConfigurationProvider()
                    .getConfiguration(RegistrationWizard2.CONFIGKEY);
            cfg.put(OPENED_URL_CONFIGKEY, url);
            mService.getConfigurationProvider().updateConfigurationNow(RegistrationWizard2.CONFIGKEY, cfg);
        }
    }
}