uri

detect if contact has photo

会有一股神秘感。 提交于 2019-12-20 21:23:34
问题 I've got an ImageView which I'm displaying a contacts picture using a Uri which always looks similar to this: content://com.android.contacts/contacts/34/photo How would I be able to detect whether this photo exists, as if it doesn't then I want to use a placeholder instead (stored in my drawable folder). At the moment it just shows a blank image. 回答1: a function to get a contacts photo uri: public Uri getPhotoUri(Integer contactid) { Cursor photoCur = getContentResolver().query

get path from Google Drive URI

眉间皱痕 提交于 2019-12-20 21:06:23
问题 I'm using Android file selection and selecting files from app storage (images, videos, documents). I have an function "getPath" . Im getting path from uri. I have no problem with gallery images or download documents. But when i select a file from google drive i cant get path. This is the google drive uri "content://com.google.android.apps.docs.storage/document/acc%3D25%3Bdoc%3D12" Can you help me about it ? This is also my "getPath" function. public static String getPath(final Context context

Do colons require encoding in URI query parameters?

我的梦境 提交于 2019-12-20 17:34:10
问题 I've noticed that Java's UriBuilder isn't encoding the : characters included in my query parameter values (ISO 8601-formatted strings). According to Wikipedia, it seems colon should be encoded. In particular, encoding the query string uses the following rules: Letters (A-Z and a-z), numbers (0-9) and the characters '.','-','~' and '_' are left as-is SPACE is encoded as '+' or %20[citation needed] All other characters are encoded as %FF hex representation with any non-ASCII characters first

Get image Uri in onActivityResult after taking photo?

邮差的信 提交于 2019-12-20 16:56:24
问题 I have this code: startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE), CAMERA_IMAGE); That allows that user to take a photo. Now how would I get the Uri of that photo in onActivityResult ? Is it an Intent extra? Is it through Intent.getData() ? 回答1: protected void onActivityResult(int requestCode, int resultCode, Intent intent){ Uri u = intent.getData(); } By the way... there's a bug with that intent in some devices. Take a look at this answer to know how to workaround it. 回答2:

Why is URN one of more popular formats used to uniquely identify the resource?

拥有回忆 提交于 2019-12-20 10:31:09
问题 I somewhat understand that URNs are used to provide unique and location independent name for the resource. Yet I fail to see their usefulness and how exactly they work: a) In order for URN to really be unique, there would have to be some central authority (similar to authority for domain names) where we could register URNs and that way ensure they are unique. Since there isn’t any such authority, how else do we make sure that our URNs are unique? And if we can’t. then what’s the point of

Uri Builder in android - '/' replaced by '%2F' and “:” is replaced by “%3A”

不打扰是莪最后的温柔 提交于 2019-12-20 10:25:50
问题 I want to build the following URI - https://10.112.88.182:8443/Vehicle/services/socialService/login ... Builder builder = new Builder(); builder.scheme(Constants.URL_SCHEME); builder.authority(host); builder.appendPath(service + "/" +method); return builder.build().toString(); where URL_SCHEME - https host - 10.112.88.182:8443/Vehicle/services/ service - socialService method - login When this code runs I get the following URI - https://10.112.88.182%3A8443%2FVehicle%2Fservices%2F

RESTful API URI Design

隐身守侯 提交于 2019-12-20 09:06:57
问题 I'm looking for some direction in regards to the URI design for a RESTful API. I'm going to have several nested linked resources and have currently designed my URI's similar to this post: Hierarchical RESTful URL design The following example isn't what I'm building but I think illustrates my situation well. (Assume that a show can only belong to one network). /networks [GET,POST] /networks/{network_id} [GET,PUT] /networks/{network_id}/shows [GET,POST] /networks/{network_id}/shows/{show_id}

Uri.parse(“file://” + ???); to access specific folder

笑着哭i 提交于 2019-12-20 06:45:12
问题 My question is two part, how can I get the following code to access this location: "/storage/emulated/0/Movies/SpecificFolder" Code: private Uri getUriFromMediaStore(int position) { int dataIndex = mMediaStoreCursor.getColumnIndex(MediaStore.Files.FileColumns.DATA); mMediaStoreCursor.moveToPosition(position); String dataString = mMediaStoreCursor.getString(dataIndex); Uri mediaUri = Uri.parse("file://" + dataString); return mediaUri; } and, when the time comes how can I access videos/files

Cannot create a file using the Uri of `ACTION_GET_CONTENT`

一笑奈何 提交于 2019-12-20 06:33:19
问题 I'm trying to select pdf file from the device and upload them to the server. ACTION_GET_CONTENT is used to select pdf from the device. sel_book.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(); intent.setType("application/pdf"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select PDF"), 1); } }); On activity result I get the Uri and save it as a String. public void

Reading sms received after a date

痴心易碎 提交于 2019-12-20 05:26:13
问题 I'm trying to read all the sms I received after a date. Here is the code: Uri SMS_CONTENT_URI = Uri.parse("content://sms"); Uri SMS_INBOX_CONTENT_URI = Uri.withAppendedPath(SMS_CONTENT_URI, "inbox"); Cursor cursor = context.getContentResolver().query( SMS_INBOX_CONTENT_URI, new String[] { "_id" }, "date>=61291393200000", null, null); //61291393200000 = 03/01/12 This returns me a empty cursor. When I was executing this code: Cursor cursor = context.getContentResolver().query( SMS_INBOX_CONTENT