List of usage examples for android.net Uri EMPTY
Uri EMPTY
To view the source code for android.net Uri EMPTY.
Click Source Link
From source file:de.appplant.cordova.plugin.notification.Asset.java
/** * Parse given PathStrings to Uris// w ww.j a v a 2s. co m * @param notification Notifications JSONObject * @return new Notification JSONObject with additional iconUri and soundUri */ public JSONObject parseURIs(JSONObject notification) { //sound String sound = notification.optString("sound", null); Uri soundUri = null; if (sound != null) { try { int soundId = (Integer) RingtoneManager.class.getDeclaredField(sound).get(Integer.class); soundUri = RingtoneManager.getDefaultUri(soundId); } catch (Exception e) { soundUri = getURIfromPath(sound); } } if (soundUri != null && soundUri != Uri.EMPTY) { try { notification.put("soundUri", soundUri.toString()); } catch (JSONException jse) { jse.printStackTrace(); } } //image String icon = notification.optString("icon", "icon"); Uri iconUri = null; iconUri = getURIfromPath(icon); if (iconUri != Uri.EMPTY && iconUri != null) { try { notification.put("iconUri", iconUri.toString()); } catch (JSONException jse) { jse.printStackTrace(); } } return notification; }
From source file:android.net.ProxyInfo.java
/** * Create a ProxyProperties that points at a HTTP Proxy. * @hide/* w w w . j a v a2s.c o m*/ */ public ProxyInfo(String host, int port, String exclList) { mHost = host; mPort = port; setExclusionList(exclList); mPacFileUrl = Uri.EMPTY; }
From source file:org.secu3.android.ErrorsActivity.java
private void setRealtime(boolean realtime) { for (int i = 0; i != Secu3Packet.SECU3_ECU_ERRORS_COUNT; i++) { errors.get(i).setEnabled(!realtime); }/*from w w w. j a va 2 s. c o m*/ adapter.notifyDataSetChanged(); ReadingInertion.setEnabled(realtime); ActivityCompat.invalidateOptionsMenu(ErrorsActivity.this); SECU3_TASK task = realtime ? SECU3_TASK.SECU3_READ_ERRORS : 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:com.android.contacts.common.model.ContactLoaderTest.java
public void testEmptyUri() { Contact result = assertLoadContact(Uri.EMPTY); assertTrue(result.isError()); }
From source file:de.appplant.cordova.plugin.notification.Asset.java
/** * The URI for a path.//w w w. j av a 2 s .c o m * * @param path The given path * * @return The URI pointing to the given path */ public Uri getURIfromPath(String path) { if (path.startsWith("res:")) { return getUriForResourcePath(path); } else if (path.startsWith("file:///")) { return getUriForAbsolutePath(path); } else if (path.startsWith("file://")) { return getUriForAssetPath(path); } else if (path.startsWith("http")) { return getUriForHTTP(path); } return Uri.EMPTY; }
From source file:org.chromium.chrome.browser.download.DownloadManagerDelegate.java
/** * @see android.app.DownloadManager#addCompletedDownload(String, String, boolean, String, * String, long, boolean)//from w ww . ja v a 2 s . com */ protected long addCompletedDownload(String fileName, String description, String mimeType, String path, long length, String originalUrl, String referer, String downloadGuid) { DownloadManager manager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mContext); boolean useSystemNotification = !notificationManager.areNotificationsEnabled(); long downloadId = -1; if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { Class<?> c = manager.getClass(); try { Class[] args = { String.class, String.class, boolean.class, String.class, String.class, long.class, boolean.class, Uri.class, Uri.class }; Method method = c.getMethod("addCompletedDownload", args); Uri originalUri = Uri.parse(originalUrl); Uri refererUri = referer == null ? Uri.EMPTY : Uri.parse(referer); downloadId = (Long) method.invoke(manager, fileName, description, true, mimeType, path, length, useSystemNotification, originalUri, refererUri); } catch (SecurityException e) { Log.e(TAG, "Cannot access the needed method."); } catch (NoSuchMethodException e) { Log.e(TAG, "Cannot find the needed method."); } catch (InvocationTargetException e) { Log.e(TAG, "Error calling the needed method."); } catch (IllegalAccessException e) { Log.e(TAG, "Error accessing the needed method."); } } else { downloadId = manager.addCompletedDownload(fileName, description, true, mimeType, path, length, useSystemNotification); } addDownloadIdMapping(downloadId, downloadGuid); return downloadId; }
From source file:org.blanco.techmun.android.cproviders.TechMunContentProvider.java
@Override public Uri insert(Uri uri, ContentValues values) { if (uri.toString().matches(MESA_CONTENT_COMENTARIOS_INSERT_PETITION_REG_EXP)) { boolean success = comentsFetcher.publishComentario(values); if (success) { return Uri.parse(CONTENT_BASE_URI + "/comentarios/"); } else {/*from w ww . j a va 2s .c o m*/ return Uri.EMPTY; } } else if (uri.toString().matches(MESA_CONTENT_MENSAJES_PETITION_REG_EXP)) { return Uri.parse(CONTENT_BASE_URI + "/mensajes/" + 123); } else { throw new UnsupportedOperationException( "Can't insert other elements that not " + "complain with comentarios expression"); } }
From source file:org.musicmod.android.app.QueryFragment.java
public void onServiceConnected(ComponentName name, IBinder service) { Bundle bundle = getArguments();//from w w w .jav a2 s .c om String action = bundle != null ? bundle.getString(INTENT_KEY_ACTION) : null; String data = bundle != null ? bundle.getString(INTENT_KEY_DATA) : null; if (Intent.ACTION_VIEW.equals(action)) { // this is something we got from the search bar Uri uri = Uri.parse(data); if (data.startsWith("content://media/external/audio/media/")) { // This is a specific file String id = uri.getLastPathSegment(); long[] list = new long[] { Long.valueOf(id) }; MusicUtils.playAll(getActivity(), list, 0); getActivity().finish(); return; } else if (data.startsWith("content://media/external/audio/albums/")) { // This is an album, show the songs on it Intent i = new Intent(Intent.ACTION_PICK); i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); i.putExtra("album", uri.getLastPathSegment()); startActivity(i); return; } else if (data.startsWith("content://media/external/audio/artists/")) { // This is an artist, show the albums for that artist Intent i = new Intent(Intent.ACTION_PICK); i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album"); i.putExtra("artist", uri.getLastPathSegment()); startActivity(i); return; } } mFilterString = bundle != null ? bundle.getString(SearchManager.QUERY) : null; if (MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action)) { String focus = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_FOCUS) : null; String artist = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_ARTIST) : null; String album = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_ALBUM) : null; String title = bundle != null ? bundle.getString(MediaStore.EXTRA_MEDIA_TITLE) : null; if (focus != null) { if (focus.startsWith("audio/") && title != null) { mFilterString = title; } else if (Audio.Albums.ENTRY_CONTENT_TYPE.equals(focus)) { if (album != null) { mFilterString = album; if (artist != null) { mFilterString = mFilterString + " " + artist; } } } else if (Audio.Artists.ENTRY_CONTENT_TYPE.equals(focus)) { if (artist != null) { mFilterString = artist; } } } } mTrackList = getListView(); mTrackList.setTextFilterEnabled(true); }
From source file:com.andrew.apolloMod.activities.QueryBrowserActivity.java
@Override public void onServiceConnected(ComponentName name, IBinder service) { if (mAdapter != null) { getQueryCursor(mAdapter.getQueryHandler(), null); }// w ww . j a v a 2 s .co m Intent intent = getIntent(); String action = intent != null ? intent.getAction() : null; if (Intent.ACTION_VIEW.equals(action)) { // this is something we got from the search bar Uri uri = intent.getData(); String path = uri.toString(); if (path.startsWith("content://media/external/audio/media/")) { // This is a specific file String id = uri.getLastPathSegment(); long[] list = new long[] { Long.valueOf(id) }; MusicUtils.playAll(this, list, 0); finish(); return; } else if (path.startsWith("content://media/external/audio/albums/")) { // This is an album, show the songs on it Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); i.putExtra("album", uri.getLastPathSegment()); startActivity(i); finish(); return; } else if (path.startsWith("content://media/external/audio/artists/")) { intent = new Intent(Intent.ACTION_VIEW); Bundle bundle = new Bundle(); bundle.putString(MIME_TYPE, Audio.Artists.CONTENT_TYPE); bundle.putString(ARTIST_KEY, uri.getLastPathSegment()); bundle.putLong(BaseColumns._ID, ApolloUtils.getArtistId(uri.getLastPathSegment(), ARTIST_ID, this)); intent.setClass(this, TracksBrowser.class); intent.putExtras(bundle); startActivity(intent); return; } } mFilterString = intent.getStringExtra(SearchManager.QUERY); if (MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action)) { String focus = intent.getStringExtra(MediaStore.EXTRA_MEDIA_FOCUS); String artist = intent.getStringExtra(MediaStore.EXTRA_MEDIA_ARTIST); String album = intent.getStringExtra(MediaStore.EXTRA_MEDIA_ALBUM); String title = intent.getStringExtra(MediaStore.EXTRA_MEDIA_TITLE); if (focus != null) { if (focus.startsWith("audio/") && title != null) { mFilterString = title; } else if (focus.equals(Audio.Albums.ENTRY_CONTENT_TYPE)) { if (album != null) { mFilterString = album; if (artist != null) { mFilterString = mFilterString + " " + artist; } } } else if (focus.equals(Audio.Artists.ENTRY_CONTENT_TYPE)) { if (artist != null) { mFilterString = artist; } } } } setContentView(R.layout.listview); mTrackList = getListView(); mTrackList.setTextFilterEnabled(true); if (mAdapter == null) { mAdapter = new QueryListAdapter(getApplication(), this, R.layout.listview_items, null, // cursor new String[] {}, new int[] {}, 0); setListAdapter(mAdapter); if (TextUtils.isEmpty(mFilterString)) { getQueryCursor(mAdapter.getQueryHandler(), null); } else { mTrackList.setFilterText(mFilterString); mFilterString = null; } } else { mAdapter.setActivity(this); setListAdapter(mAdapter); mQueryCursor = mAdapter.getCursor(); if (mQueryCursor != null) { init(mQueryCursor); } else { getQueryCursor(mAdapter.getQueryHandler(), mFilterString); } } LinearLayout emptyness = (LinearLayout) findViewById(R.id.empty_view); emptyness.setVisibility(View.GONE); }
From source file:com.amazon.android.tv.tenfoot.ui.activities.ContentBrowseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.content_browse_activity_layout); Helpers.handleActivityEnterFadeTransition(this, ACTIVITY_ENTER_TRANSITION_FADE_DURATION); mContentTitle = (TextView) findViewById(R.id.content_detail_title); CalligraphyUtils.applyFontToTextView(this, mContentTitle, ConfigurationManager.getInstance(this).getTypefacePath(ConfigurationConstants.BOLD_FONT)); mContentDescription = (TextView) findViewById(R.id.content_detail_description); CalligraphyUtils.applyFontToTextView(this, mContentDescription, ConfigurationManager.getInstance(this).getTypefacePath(ConfigurationConstants.LIGHT_FONT)); mContentImage = (ImageView) findViewById(R.id.content_image); mContentImage.setImageURI(Uri.EMPTY); // Get display/background size Display display = getWindowManager().getDefaultDisplay(); Point windowSize = new Point(); display.getSize(windowSize);//from ww w . j a v a 2 s . co m int imageWidth = (int) getResources().getDimension(R.dimen.content_image_width); int imageHeight = (int) getResources().getDimension(R.dimen.content_image_height); int gradientSize = (int) getResources().getDimension(R.dimen.content_image_gradient_size); // Create the background Bitmap background = BackgroundImageUtils.createBackgroundWithPreviewWindow(windowSize.x, windowSize.y, imageWidth, imageHeight, gradientSize, ContextCompat.getColor(this, R.color.browse_background_color)); mBackgroundWithPreview = new BitmapDrawable(getResources(), background); // Set the background mMainFrame = findViewById(R.id.main_frame); mMainFrame.setBackground(mBackgroundWithPreview); }