Example usage for android.net Uri EMPTY

List of usage examples for android.net Uri EMPTY

Introduction

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

Prototype

Uri EMPTY

To view the source code for android.net Uri EMPTY.

Click Source Link

Document

The empty URI, equivalent to "".

Usage

From source file:de.appplant.cordova.emailcomposer.EmailComposerImpl.java

/**
 * The URI for a resource./*from ww  w .j  a  v a 2 s . c o m*/
 *
 * @param path
 * The given relative path.
 * @param ctx
 * The application context.
 * @return
 * The URI pointing to the given path
 */
@SuppressWarnings("ResultOfMethodCallIgnored")
private Uri getUriForResourcePath(String path, Context ctx) {
    String resPath = path.replaceFirst("res://", "");
    String fileName = resPath.substring(resPath.lastIndexOf('/') + 1);
    String resName = fileName.substring(0, fileName.lastIndexOf('.'));
    String extension = resPath.substring(resPath.lastIndexOf('.'));
    File dir = ctx.getExternalCacheDir();

    if (dir == null) {
        Log.e("EmailComposer", "Missing external cache dir");
        return Uri.EMPTY;
    }

    String storage = dir.toString() + ATTACHMENT_FOLDER;
    int resId = getResId(resPath, ctx);
    File file = new File(storage, resName + extension);

    if (resId == 0) {
        Log.e("EmailComposer", "File not found: " + resPath);
    }

    new File(storage).mkdir();

    try {
        Resources res = ctx.getResources();
        FileOutputStream outStream = new FileOutputStream(file);
        InputStream inputStream = res.openRawResource(resId);

        copyFile(inputStream, outStream);
        outStream.flush();
        outStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return Uri.fromFile(file);
}

From source file:org.secu3.android.MainActivity.java

private void setRawMode(boolean raw) {
    SECU3_TASK task = raw ? SECU3_TASK.SECU3_RAW_SENSORS : SECU3_TASK.SECU3_READ_SENSORS;
    startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK, Uri.EMPTY, this, Secu3Service.class)
            .putExtra(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK_PARAM, task.ordinal()));
}

From source file:org.secu3.android.DiagnosticsActivity.java

@Override
protected void onPause() {
    if (OpCompNc != null) {
        ((ProtoFieldInteger) OpCompNc.findField(R.string.op_comp_nc_operation_title))
                .setValue(Secu3Packet.OPCODE_DIAGNOST_LEAVE);
        ((ProtoFieldInteger) OpCompNc.findField(R.string.op_comp_nc_operation_code_title)).setValue(0);
        startService(/*  ww w  . j  a  v a  2 s .  c  om*/
                new Intent(Secu3Service.ACTION_SECU3_SERVICE_SEND_PACKET, Uri.EMPTY, this, Secu3Service.class)
                        .putExtra(Secu3Service.ACTION_SECU3_SERVICE_SEND_PACKET_PARAM_PACKET, OpCompNc));
    }
    unregisterReceiver(receiver);
    super.onPause();
}

From source file:de.appplant.cordova.emailcomposer.EmailComposerImpl.java

/**
 * The URI for a base64 encoded content.
 *
 * @param content/* w w w .ja  va 2 s .c  om*/
 * The given base64 encoded content.
 * @param ctx
 * The application context.
 * @return
 * The URI including the given content.
 */
@SuppressWarnings("ResultOfMethodCallIgnored")
private Uri getUriForBase64Content(String content, Context ctx) {
    String resName = content.substring(content.indexOf(":") + 1, content.indexOf("//"));
    String resData = content.substring(content.indexOf("//") + 2);
    File dir = ctx.getExternalCacheDir();
    byte[] bytes;

    try {
        bytes = Base64.decode(resData, 0);
    } catch (Exception ignored) {
        Log.e("EmailComposer", "Invalid Base64 string");
        return Uri.EMPTY;
    }

    if (dir == null) {
        Log.e("EmailComposer", "Missing external cache dir");
        return Uri.EMPTY;
    }

    String storage = dir.toString() + ATTACHMENT_FOLDER;
    File file = new File(storage, resName);

    new File(storage).mkdir();

    try {
        FileOutputStream outStream = new FileOutputStream(file);

        outStream.write(bytes);
        outStream.flush();
        outStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return Uri.fromFile(file);
}

From source file:org.secu3.android.MainActivity.java

void update(Intent intent) {
    if (Secu3Service.EVENT_SECU3_SERVICE_STATUS_ONLINE.equals(intent.getAction())) {
        boolean isOnline = intent.getBooleanExtra(Secu3Service.EVENT_SECU3_SERVICE_STATUS, false);
        String s = isOnline ? getString(R.string.status_online) : getString(R.string.status_offline);
        textViewStatus.setText(s);/*ww w.j  a va2  s  .  c  o  m*/
        if (isOnline && !this.isOnline) {
            this.isOnline = true;
            startService(
                    new Intent(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK, Uri.EMPTY, this, Secu3Service.class)
                            .putExtra(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK_PARAM,
                                    SECU3_TASK.SECU3_READ_FW_INFO.ordinal()));
            setRawMode(rawSensors);
        }
    } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PACKET.equals(intent.getAction())) {
        Secu3Packet packet = intent.getParcelableExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAM_PACKET);
        if (packet != null) {
            switch (packet.getPacketIdResId()) {
            case R.string.packet_type_sendor_dat:
                boolean errors = ((ProtoFieldInteger) packet.getField(R.string.sensor_dat_errors_title))
                        .getValue() != 0;
                if (errors != this.errors) {
                    this.errors = errors;
                    ActivityCompat.invalidateOptionsMenu(this);
                }
                if (!rawSensors) {
                    int bitfield = ((ProtoFieldInteger) packet.getField(R.string.sensor_dat_bitfield_title))
                            .getValue();
                    textViewData.setText(String.format(Locale.US, sensorsFormat,
                            ((ProtoFieldInteger) packet.getField(R.string.sensor_dat_rpm_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_map_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_voltage_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_temperature_title))
                                    .getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_angle_correction_title))
                                    .getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_knock_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_knock_retard_title))
                                    .getValue(),
                            ((ProtoFieldInteger) packet.getField(R.string.sensor_dat_air_flow_title))
                                    .getValue(),
                            Secu3Packet.bitTest(bitfield, Secu3Packet.BITNUMBER_EPHH_VALVE),
                            Secu3Packet.bitTest(bitfield, Secu3Packet.BITNUMBER_CARB),
                            Secu3Packet.bitTest(bitfield, Secu3Packet.BITNUMBER_GAS),
                            Secu3Packet.bitTest(bitfield, Secu3Packet.BITNUMBER_EPM_VALVE),
                            Secu3Packet.bitTest(bitfield, Secu3Packet.BITNUMBER_COOL_FAN),
                            Secu3Packet.bitTest(bitfield, Secu3Packet.BITNUMBER_ST_BLOCK),
                            ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_addi1_voltage_title))
                                    .getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_addi2_voltage_title))
                                    .getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_tps_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.sensor_dat_choke_position_title))
                                    .getValue()));

                    if (protocol_version >= SettingsActivity.PROTOCOL_28082013_SUMMER_RELEASE) {
                        textViewDataExt.setText(String.format(Locale.US, speedFormat,
                                packetUtils.calcSpeed(
                                        ((ProtoFieldInteger) packet.getField(R.string.sensor_dat_speed_title))
                                                .getValue()),
                                packetUtils.calcDistance(((ProtoFieldInteger) packet
                                        .getField(R.string.sensor_dat_distance_title)).getValue())));
                    }
                }
                break;
            case R.string.packet_type_adcraw_dat:
                if (rawSensors) {
                    textViewDataExt.setText(null);
                    textViewData.setText(String.format(Locale.US, sensorsRawFormat,
                            ((ProtoFieldFloat) packet.getField(R.string.adcraw_map_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.adcraw_voltage_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.adcraw_temperature_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.adcraw_knock_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.adcraw_tps_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.adcraw_addi1_title)).getValue(),
                            ((ProtoFieldFloat) packet.getField(R.string.adcraw_addi2_title)).getValue()));
                }
                break;
            case R.string.packet_type_fwinfo_dat:
                textFWInfo.setText(
                        ((ProtoFieldString) packet.findField(R.string.fwinfo_dat_data_title)).getValue());
                fwOptions = ((ProtoFieldInteger) packet.findField(R.string.fwinfo_dat_options_title))
                        .getValue();
                break;
            default:
                break;
            }
        }
    }
}

From source file:org.secu3.android.ErrorsActivity.java

void update(Intent intent) {
    if (Secu3Service.EVENT_SECU3_SERVICE_STATUS_ONLINE.equals(intent.getAction())) {
        boolean isOnline = intent.getBooleanExtra(Secu3Service.EVENT_SECU3_SERVICE_STATUS, false);
        if (isOnline && !this.isOnline) {
            this.isOnline = true;
            setRealtime(RealtimeError.isChecked());
        }/*  ww w . j  av a 2  s.  co m*/
        String s = isOnline ? getString(R.string.status_online) : getString(R.string.status_offline);
        errorsTextViewStatus.setText(s);
    } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_SKELETON_PACKET.equals(intent.getAction())) {
        Secu3Packet packet = intent
                .getParcelableExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAM_SKELETON_PACKET);
        if (packet != null) {
            if (packet.getNameId() == R.string.ce_saved_err_title)
                CeSavedError = packet;
            else if (packet.getNameId() == R.string.op_comp_nc_title)
                OpCompNc = packet;
        }
    } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PACKET.equals(intent.getAction())) {
        Secu3Packet packet = intent.getParcelableExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAM_PACKET);
        if (packet != null) {
            if (packet.getNameId() == R.string.ce_saved_err_title) {
                updateFlags(((ProtoFieldInteger) packet.getField(R.string.ce_saved_err_data_title)).getValue());
                startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK, Uri.EMPTY, this,
                        Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK_PARAM,
                                SECU3_TASK.SECU3_READ_SENSORS.ordinal()));
            } else if (packet.getNameId() == R.string.ce_err_codes_title) {
                updateFlags(((ProtoFieldInteger) packet.getField(R.string.ce_err_codes_data_title)).getValue());
            }
            if (packet.getNameId() == R.string.op_comp_nc_title) {
                if (((ProtoFieldInteger) packet.getField(R.string.op_comp_nc_operation_title))
                        .getValue() == Secu3Packet.OPCODE_CE_SAVE_ERRORS) {
                    Toast.makeText(this, String.format(getString(R.string.params_saved_error_code),
                            ((ProtoFieldInteger) packet.getField(R.string.op_comp_nc_operation_code_title))
                                    .getValue()),
                            Toast.LENGTH_LONG).show();
                }
            }
        }
    }
}

From source file:com.android.deskclock.data.TimerModel.java

/**
 * @return {@code true} iff the ringtone to play for all timers is the silent ringtone
 */
boolean isTimerRingtoneSilent() {
    return Uri.EMPTY.equals(getTimerRingtoneUri());
}

From source file:org.secu3.android.DiagnosticsActivity.java

@Override
protected void onResume() {
    OpCompNc = null;/*from   w ww  .  ja  v  a 2  s .  c o m*/
    DiagOutDat = null;
    registerReceiver(receiver, receiver.intentFilter);
    startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON, Uri.EMPTY, this,
            Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM,
                    R.string.op_comp_nc_title));
    startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON, Uri.EMPTY, this,
            Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_OBTAIN_PACKET_SKELETON_PARAM,
                    R.string.diagout_dat_title));
    super.onResume();
}

From source file:org.symptomcheck.capstone.fragments.BaseFragment.java

private Uri getDefaultUriProvider() {

    Uri uriContentProvider = Uri.EMPTY;// = ContentProvider.createUri(Patient.class, null);
    switch (getFragmentType()) {
    case FRAGMENT_TYPE_PATIENT:
        uriContentProvider = ContentProvider.createUri(Patient.class, null);
        break;/*from  www  . j  av a  2s  .co m*/
    case FRAGMENT_TYPE_DOCTORS:
        uriContentProvider = ContentProvider.createUri(Doctor.class, null);
        break;
    case FRAGMENT_TYPE_CHECKIN:
        uriContentProvider = ContentProvider.createUri(CheckIn.class, null);
        break;
    case FRAGMENT_TYPE_MEDICINES:
        uriContentProvider = ContentProvider.createUri(PainMedication.class, null);
        break;
    case FRAGMENT_TYPE_EXPERIENCES:
        uriContentProvider = ContentProvider.createUri(PatientExperience.class, null);
        break;
    case FRAGMENT_TYPE_ONLINE_CHECKIN:
        uriContentProvider = ContentProvider.createUri(CheckInOnlineWrapper.class, null);
        break;

    default:
        break;
    }
    return uriContentProvider;
}

From source file:org.secu3.android.DiagnosticsActivity.java

void update(Intent intent) {
    if (Secu3Service.EVENT_SECU3_SERVICE_STATUS_ONLINE.equals(intent.getAction())) {
        boolean isOnline = intent.getBooleanExtra(Secu3Service.EVENT_SECU3_SERVICE_STATUS, false);
        if (isOnline && !this.isOnline) {
            this.isOnline = true;
        }// www .j  a va2 s .  c om
        String s = isOnline ? getString(R.string.status_online) : getString(R.string.status_offline);
        textViewStatus.setText(s);
    } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PACKET.equals(intent.getAction())) {
        Secu3Packet packet = intent.getParcelableExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAM_PACKET);
        if (packet != null) {
            if (packet.getNameId() == R.string.diaginp_dat_title) {
                PacketUtils.setDiagInpFromPacket((ParamItemsAdapter) inputFragment.getListAdapter(), packet);
                ((ParamItemsAdapter) inputFragment.getListAdapter()).notifyDataSetChanged();
            } else if ((OpCompNc != null) && (DiagOutDat != null)) {
                ((ProtoFieldInteger) OpCompNc.findField(R.string.op_comp_nc_operation_title))
                        .setValue(Secu3Packet.OPCODE_DIAGNOST_ENTER);
                ((ProtoFieldInteger) OpCompNc.findField(R.string.op_comp_nc_operation_code_title)).setValue(0);
                startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_SEND_PACKET, Uri.EMPTY, this,
                        Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_SEND_PACKET_PARAM_PACKET,
                                OpCompNc));
                onParamItemChange(null);
            }
        }
    } else if (Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_SKELETON_PACKET.equals(intent.getAction())) {
        Secu3Packet packet = intent
                .getParcelableExtra(Secu3Service.EVENT_SECU3_SERVICE_RECEIVE_PARAM_SKELETON_PACKET);
        if (packet != null) {
            if (packet.getNameId() == R.string.op_comp_nc_title) {
                OpCompNc = packet;
            } else if (packet.getNameId() == R.string.diagout_dat_title) {
                DiagOutDat = packet;
            }
        }
    }
}