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.plugin.notification.Asset.java

/**
 * The URI for a file./*from   w  w  w.j  a v a  2s.c om*/
 * 
 * @param path
 *            The given absolute path
 * 
 * @return The URI pointing to the given path
 */
private Uri getUriForAbsolutePath(String path) {
    String absPath = path.replaceFirst("file://", "");
    File file = new File(absPath);
    if (!file.exists()) {
        Log.e("Asset", "File not found: " + file.getAbsolutePath());
        return Uri.EMPTY;
    }
    return Uri.fromFile(file);
}

From source file:android.net.ProxyInfo.java

private ProxyInfo(String host, int port, String exclList, String[] parsedExclList) {
    mHost = host;/*from   w w  w  .  ja va2 s .  c  o  m*/
    mPort = port;
    mExclusionList = exclList;
    mParsedExclusionList = parsedExclList;
    mPacFileUrl = Uri.EMPTY;
}

From source file:org.yammp.app.QueryFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {

    // Dialog doesn't allow us to wait for a result, so we need to store
    // the info we need for when the dialog posts its result
    mQueryCursor.moveToPosition(position);
    if (mQueryCursor.isBeforeFirst() || mQueryCursor.isAfterLast())
        return;//from  w w  w.  j av  a2s. c o  m
    String selectedType = mQueryCursor.getString(mQueryCursor.getColumnIndexOrThrow(Audio.Media.MIME_TYPE));

    if ("artist".equals(selectedType)) {
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album");
        intent.putExtra("artist", Long.valueOf(id).toString());
        startActivity(intent);
    } else if ("album".equals(selectedType)) {
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
        intent.putExtra("album", Long.valueOf(id).toString());
        startActivity(intent);
    } else if (position >= 0 && id >= 0) {
        long[] list = new long[] { id };
        MusicUtils.playAll(getActivity(), list, 0);
    } else {
        Log.e("QueryBrowser", "invalid position/id: " + position + "/" + id);
    }
}

From source file:org.yammp.fragment.QueryFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {

    // Dialog doesn't allow us to wait for a result, so we need to store
    // the info we need for when the dialog posts its result
    mQueryCursor.moveToPosition(position);
    if (mQueryCursor.isBeforeFirst() || mQueryCursor.isAfterLast())
        return;//from  ww w .j  a v  a 2 s.c  o m
    String selectedType = mQueryCursor.getString(mQueryCursor.getColumnIndexOrThrow(Audio.Media.MIME_TYPE));

    if ("artist".equals(selectedType)) {
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album");
        intent.putExtra("artist", Long.valueOf(id).toString());
        startActivity(intent);
    } else if ("album".equals(selectedType)) {
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
        intent.putExtra("album", Long.valueOf(id).toString());
        startActivity(intent);
    } else if (position >= 0 && id >= 0) {
        long[] list = new long[] { id };
        mUtils.playAll(list, 0);
    } else {
        Log.e("QueryBrowser", "invalid position/id: " + position + "/" + id);
    }
}

From source file:android.net.ProxyInfo.java

/**
 * @hide/*from   w w  w.ja v  a2  s. c om*/
 */
public ProxyInfo(ProxyInfo source) {
    if (source != null) {
        mHost = source.getHost();
        mPort = source.getPort();
        mPacFileUrl = source.mPacFileUrl;
        mExclusionList = source.getExclusionListAsString();
        mParsedExclusionList = source.mParsedExclusionList;
    } else {
        mPacFileUrl = Uri.EMPTY;
    }
}

From source file:de.appplant.cordova.plugin.notification.Asset.java

/**
 * The URI for an asset./*from   w  ww .j  a  v a  2  s. c  o  m*/
 * 
 * @param path
 *            The given asset path
 * 
 * @return The URI pointing to the given path
 */
private Uri getUriForAssetPath(String path) {
    String resPath = path.replaceFirst("file:/", "www");
    String fileName = resPath.substring(resPath.lastIndexOf('/') + 1);
    File dir = activity.getExternalCacheDir();
    if (dir == null) {
        Log.e("Asset", "Missing external cache dir");
        return Uri.EMPTY;
    }
    String storage = dir.toString() + STORAGE_FOLDER;
    File file = new File(storage, fileName);
    new File(storage).mkdir();
    try {
        AssetManager assets = activity.getAssets();
        FileOutputStream outStream = new FileOutputStream(file);
        InputStream inputStream = assets.open(resPath);
        copyFile(inputStream, outStream);
        outStream.flush();
        outStream.close();
        return Uri.fromFile(file);
    } catch (Exception e) {
        Log.e("Asset", "File not found: assets/" + resPath);
        e.printStackTrace();
    }
    return Uri.EMPTY;
}

From source file:com.maskyn.fileeditorpro.util.AccessStorageApi.java

public static String getName(Context context, Uri uri) {

    if (uri == null || uri.equals(Uri.EMPTY))
        return "";

    String fileName = "";
    try {// w  ww . j  a  va 2s . c om
        String scheme = uri.getScheme();
        if (scheme.equals("file")) {
            fileName = uri.getLastPathSegment();
        } else if (scheme.equals("content")) {
            String[] proj = { MediaStore.Images.Media.DISPLAY_NAME };
            Cursor cursor = context.getContentResolver().query(uri, proj, null, null, null);
            if (cursor != null && cursor.getCount() != 0) {
                int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DISPLAY_NAME);
                cursor.moveToFirst();
                fileName = cursor.getString(columnIndex);
            }
            if (cursor != null) {
                cursor.close();
            }
        }
    } catch (Exception ex) {
        return "";
    }
    return fileName;
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(PreferenceManager.getDefaultSharedPreferences(this)
            .getBoolean(getString(R.string.pref_night_mode_key), false) ? R.style.AppBaseTheme
                    : R.style.AppBaseTheme_Light);
    setContentView(R.layout.activity_main);

    packetUtils = new PacketUtils(this);

    sensorsFormat = getString(R.string.sensors_format);
    speedFormat = getString(R.string.speed_format);
    sensorsRawFormat = getString(R.string.sensors_raw_format);
    textViewData = (TextView) findViewById(R.id.textViewData);
    textViewDataExt = (TextView) findViewById(R.id.textViewDataExt);
    textViewStatus = (TextView) findViewById(R.id.mainTextViewStatus);
    textFWInfo = (TextView) findViewById(R.id.mainTextFWInfo);

    receiver = new ReceiveMessages();

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Secu3Droid wakelock");

    if (savedInstanceState != null) {
        textViewData.setText(savedInstanceState.getString(DATA));
        textViewStatus.setText(savedInstanceState.getString(STATUS));
        rawSensors = savedInstanceState.getBoolean(RAW_SENSORS);
    }/*from   w ww . j a v a 2 s .co m*/

    setRawMode(rawSensors);

    logButtonLayout = (LinearLayout) findViewById(R.id.mainLogButtonLayout);

    View.OnClickListener logButtonListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.mainLogButton1:
                startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK, Uri.EMPTY, v.getContext(),
                        Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK_PARAM,
                                SECU3_TASK.SECU3_SET_LOG_MARKER_1.ordinal()));
                break;
            case R.id.mainLogButton2:
                startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK, Uri.EMPTY, v.getContext(),
                        Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK_PARAM,
                                SECU3_TASK.SECU3_SET_LOG_MARKER_2.ordinal()));
                break;
            case R.id.mainLogButton3:
                startService(new Intent(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK, Uri.EMPTY, v.getContext(),
                        Secu3Service.class).putExtra(Secu3Service.ACTION_SECU3_SERVICE_SET_TASK_PARAM,
                                SECU3_TASK.SECU3_SET_LOG_MARKER_3.ordinal()));
                break;
            default:
                break;
            }

        }
    };

    Button b = (Button) findViewById(R.id.mainLogButton1);
    b.setOnClickListener(logButtonListener);
    b = (Button) findViewById(R.id.mainLogButton2);
    b.setOnClickListener(logButtonListener);
    b = (Button) findViewById(R.id.mainLogButton3);
    b.setOnClickListener(logButtonListener);

    super.onCreate(savedInstanceState);
}

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

private void paramsRead() {
    progressBar.setVisibility(ProgressBar.VISIBLE);
    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_PARAMS.ordinal()));
    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()));
}

From source file:com.google.samples.apps.iosched.videolibrary.VideoLibraryFragment.java

@Override
public Uri getDataUri(final VideoLibraryQueryEnum query) {
    switch (query) {
    case VIDEOS://  www.j a  va 2s.  c o  m
        return ScheduleContract.Videos.CONTENT_URI;
    case MY_VIEWED_VIDEOS:
        return ScheduleContract.MyViewedVideos.CONTENT_URI;
    default:
        return Uri.EMPTY;
    }
}