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.
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.
I want to know if there any method to check if my Skype client is sign in or sign out inside my Andriod Application. Actually I'm using Skype Uri to perform my App functionality.
Anyone can help me. Thanks !
It's not perfect, but what I'm doing is to check the number of Skype contacts in the Android Contacts DB. With later version of Skype (I'm using 4.7.0.45315) when you log out it clears that user's Skype contacts.
final String skypeTestCallID = "echo123";
ContentResolver cr = getContentResolver();
Cursor skypeContactsCursor = cr.query(ContactsContract.Data.CONTENT_URI,
null, "mimetype = 'vnd.android.cursor.item/com.skype.android.videocall.action' "
+ "and data_sync1 != '" + skypeTestCallID + "'", null, null);
boolean isLoggedInToSkype = skypeContactsCursor.getCount() == 0;
<etc>
The obvious flaw is that you can't differentiate between being 'not logged in' and 'logged in, with no contacts in your account', but for most scenarios it's a close enough approximation.
If anyone has a better approach I'd be glad to hear about it.
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.
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'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.