天道酬勤,学无止境

android-contentresolver

Display image from URI with "content://" scheme with Glide on Android Q

Questions around Android Q and Glide have been asked before but I'm not able to put them all together, so I hope someone is willing to help. I'm saving images, downloaded from the cloud(Firebase) or chosen from gallery or taken with the camera, to local storage. I used to save it in the app's folder and could add it to the gallery, but with Android Q that is not possible anymore. So I changed my app to use the MediaStore and ContentResolver to access files and save it. Files are saved in the Pictures directory of MediaStore.Images.Media.EXTERNAL_CONTENT_URI. StorageHandler: public Uri

2022-05-03 08:46:14    分类:问答    android   android-glide   android-contentresolver   mediastore   android-10.0

Trying to read SMS/MMS on Android and geting java.lang.NullPointerException

问题 我正在尝试在 Android 上阅读 SMS/MMS,并且我遵循了答案,在编写代码并尝试在三星设备上的 Android OS 6.0.1 上运行它时,出现以下异常: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at android.os.Parcel.readException(Parcel.java:1626) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) at android.content.ContentProviderProxy.query(ContentProviderNative.java:421) at android.content.ContentResolver.query(ContentResolver.java:502) at

2022-04-29 05:41:17    分类:技术分享    java   android   android-contentresolver   android-mms   android-sms

Android ContentResolver query sometimes not starting ContentProvider process

问题 我一直在应用程序 A 中实现自己的自定义内容提供程序,并希望使用在 A 中定义的适当自定义 URI 从调用 ContentResolver.query(...) 的单独应用程序 B 查询其数据库。 当 A 在我启动 B 之前运行时一切顺利(因此 A 的进程仍在后台运行)。 但是,当我杀死 A 的进程时,B 无法查询 A 的数据库! 我认为查询内容提供者会自动启动其进程,以便可以检索数据。 我错过了什么吗? 一些澄清: 我正确设置了内容提供者。 权限字符串中的拼写错误没有问题,权限也没有问题,提供者在 A 的清单中正确声明,具有正确的名称、权限、导出和启用。 我回顾了我能找到的关于自定义内容提供商的任何示例,以确保它完全正确。 包管理器告诉我提供程序已在系统中正确注册(即使其进程未运行)。 我验证了使用List<PackageInfo> info = context.getPackageManager().getInstalledPackages(PackageManager.GET_PROVIDERS); 当 B 无法查询 A 的提供者时,logcat 的错误消息是E/ActivityThread: Failed to find provider info for com.example.provider.MyProvider在这种情况下,既没有调用 A

2022-04-25 06:41:07    分类:技术分享    android   android-contentprovider   android-contentresolver

Update contact pictures - support other providers like outlook

The code at the bottom shows how I update contact pictures from my app. This works well, if the user uses sim, phone and google contacts and similar. But if he uses the outlook app, the outlook app does overwrite the images set by my app again after some time. Can I somehow solve that? Can I force to overwrite the outlook image as well so that outlook syncs my new photo instead of their old one? Code byte[] photo = ImageUtil.convertImageToByteArray(bitmap, true); ContentValues values = new ContentValues(); int photoId = -1; String where = ContactsContract.Data.RAW_CONTACT_ID + " == " + contact

2022-04-16 12:46:23    分类:问答    android   android-contacts   android-contentresolver   contactscontract

How can I call getContentResolver in android?

I'm writing a library class to encapsulate some of my logic in my first Android app. One of the functions which I want to encapsulate is a function which queries the address book. As such, it needs a ContentResolver. I'm trying to figure out how to keep the library functions black-boxed... that is, to avoid having each Activity pass in its own context to get a ContentResolver. Problem is I cannot for the life of me figure out how to get a ContentResolver from within my library function. I can't find an import that contains getContentResolver. Googling said to use getContext to get a Context on

2022-04-04 18:29:00    分类:问答    android   android-context   android-contentresolver

Android ContentResolver query sometimes not starting ContentProvider process

I have been implementing my own custom content provider in an app A and want to query its database from a separate app B that calls ContentResolver.query(...) using the appropriate custom URI defined in A. All goes well when A has been running just before I launch B (thus A's process still running in the background). However when I kill A's process, then B fails to query A's database! I thought querying a content provider would automatically start its process so the data can be retrieved. Am I missing something? Some clarifications: I properly set up the content provider. There is no problem

2022-04-04 15:13:13    分类:问答    android   android-contentprovider   android-contentresolver

Trying to read SMS/MMS on Android and geting java.lang.NullPointerException

I'm trying to read SMS/MMS on Android, and I have followed the answer, when writing the code and try to run it on an Android OS 6.0.1 on Samsung device I got the following exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at android.os.Parcel.readException(Parcel.java:1626) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) at android.content.ContentProviderProxy.query

2022-03-23 20:03:17    分类:问答    java   android   android-contentresolver   android-mms   android-sms