I am using a QuickContactBadge. Now I get this messages on a Sony Xperia P. I developed the app on CyanogenMod and eveything was fine.
Unable to open content: content://com.android.contacts/contacts/939/photo
java.io.FileNotFoundException: content://com.android.contacts/contacts/939/photo
This is my code:
projection = new String[] {
ContactsContract.CommonDataKinds.Phone._ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.PHOTO_URI };
contactCursor = getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
projection, null, null, null);
...
thumbnail = contactCursor.getString(contactCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI));
...
quickContactBadge.setImageURI(Uri.parse(ThumbnailString));
My suggestion was that the Sony ROM doesn't deliver an valid PHOTO_URI but it looks legit.
The Solution is quit simple.
I discovered this Question which solves the Problem.
Related
I want to show to the user his latest photos or screenshot made by him in my app.
String[] projection = new String[]{
MediaStore.Images.ImageColumns._ID,
MediaStore.Images.ImageColumns.DATA,
MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME,
MediaStore.Images.ImageColumns.DATE_TAKEN,
MediaStore.Images.ImageColumns.MIME_TYPE
};
final Cursor cursor = getActivity().getContentResolver()
.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null,
null, MediaStore.Images.ImageColumns.DATE_TAKEN + " DESC");
In order to get the latest photos on the phone i use Cursor.
How can i check if the picture/screenshot was taken on this phone?
I don't want unrelated WhatsApp photos (or other apps) to be shown, only photos from camera roll and screenshots.
I think this post https://stackoverflow.com/a/4495753/2014374 should help you finding your answer.
It used content resolver over Images.Media.EXTERNAL_CONTENT_URI and filters the results by getting the Media.BUCKET_ID from media bucket name "/DCIM/Camera"; Hope this helps.
Hi i have an app which reads the browserhistory with this code
String[] proj = new String[] { Browser.BookmarkColumns.DATE, Browser.BookmarkColumns.URL };
String sel = Browser.BookmarkColumns.BOOKMARK + " = 0";
Cursor mCur = context.getContentResolver().query(Browser.BOOKMARKS_URI, proj, sel, null, Browser.BookmarkColumns.DATE + " DESC");
But it seems fom device to devie it logs only with one special browser:
s4 (4.2.2)=chrome
s5 (4.2.2)=chrome
htc one (4.2.2)=default browser
Samsung ace (4.1.2)=default browser
on what does it depend which browser logs it?
that depends if a browser logs to Android built-in Content Provider for the browser activity. Some browsers might, but not all of them do.
Usually the stock browser, the one that comes installed on the device, do. But there're no guarantees that others will.
Where would I get started to create an app that would grab your Album Art based on Album or Artist of the mp3 from the internet (ie. via amazon, play.com, etc..)?
I would likely be using Eclipse.
Cusor cur = getContentResolver().query(Albums.EXTERNAL_CONTENT_URI, new String[] {Albums.ALBUM_ART}, Albums._ID + "=?", new String[] {albumid}, null);
Album Artist is still undocumented and not available before 2.3.3, I believe.
i'm trying to access alarm provider to get all enabled alarm information.
so i wrote this :
public static final Uri CONTENT_URI =
Uri.parse("content://com.android.deskclock/alarm");
ContentResolver cr = getContentResolver();
Cursor c = null;
c = cr.query(
CONTENT_URI, ALARM_QUERY_COLUMNS,
null, null, DEFAULT_SORT_ORDER);
but it seemed to have the permission problem??
it always crashed QQ......could someone help me?
As #CommonsWare points out this only works on certain devices. Although with the other alarm URIs it was possible to read on most platforms. However in Honeycomb they have changed the access required and you can no longer use a content provider to get to the alarms.
I've read related several questions here and can't find the answer to this: I have an Android 2.1 device (HTC Incredible). My app, however, must be compatible with early (pre SDK 5) devices, so I am using the deprecated format of filter URI:
Uri contactUri = Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL, Uri.encode(number));
Cursor C = context.getContentResolver().query(contactUri , null, null, null, null));
The number is of the form 15555551212. This fails to find the Contact, at least on my device. However, changing to the new (SDK 5 and later) ContactsContract format URI
Uri contactUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
Cursor C = context.getContentResolver().query(contactUri , null, null, null, null));
results in success. Originally, the corresponding number in the Contact was in the format +1 555 555 5555, but I changed it to exactly match the input number 15555555555 and the old format URI still fails. In both cases, the new format URI succeeds.
Does anyone have any thoughts as to why this is the case? I'm stumped!
That was it. The old API just won't do. Needing to be compatible with older devices, I used Reflection to laod and use the new API calls (ContactsContract) on API > 4.