android-contentresolver

Convert content:// URI to actual path in Android 4.4

空扰寡人 提交于 2019-12-27 10:37:41
问题 I tried a solution (see below) that works fine, except in Android 4.4 the call to startActivityForResult() brings up an activity titled "Open from", which has "Recent", "Images", "Downloads" as well as several apps to pick from. When I choose "Images" and try to resolve the returned content URI (using the code below), the call to cursor.getString() returns null. If I choose the exact same file using the Gallery app, cursor.getString() returns a file path. I've only tested this in API levels

Using a content Uri for alarm notification

喜欢而已 提交于 2019-12-25 10:56:23
问题 I have given the user the choice of what sound they want in their notifications but can't make it work. It always plays the default sound. They choose their sound in the preferences <RingtonePreference android:defaultValue="content://settings/system/notification_sound" android:key="alarmsound" android:ringtoneType="notification" android:showDefault="true" android:summary="Choose Your Alarm Sound" android:title="Alarm Sound" /> </PreferenceCategory> Then it is pulled up in my notification

Using a content Uri for alarm notification

烂漫一生 提交于 2019-12-25 10:56:09
问题 I have given the user the choice of what sound they want in their notifications but can't make it work. It always plays the default sound. They choose their sound in the preferences <RingtonePreference android:defaultValue="content://settings/system/notification_sound" android:key="alarmsound" android:ringtoneType="notification" android:showDefault="true" android:summary="Choose Your Alarm Sound" android:title="Alarm Sound" /> </PreferenceCategory> Then it is pulled up in my notification

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

百般思念 提交于 2019-12-25 09:22:30
问题 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

Android API below 19 equivalent for ContentResolver takePersistableUriPermission

浪尽此生 提交于 2019-12-24 17:17:15
问题 I use this to let the user select file, after the selection I store in shared prefs only the URI of the file. In the future the user can open this file - So I have the URI and therefore it can be done final Intent intent = new Intent(); if (Integer.valueOf(android.os.Build.VERSION.SDK_INT) >= 19) { intent.setAction(Intent.ACTION_OPEN_DOCUMENT); } else { intent.setAction(Intent.ACTION_GET_CONTENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("application/msword,application

Update contact pictures - support other providers like outlook

▼魔方 西西 提交于 2019-12-24 07:26:34
问题 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

InsertAPN() Method Does Not Write APN Settings - Android 2.3.6

纵饮孤独 提交于 2019-12-24 06:58:21
问题 I have an android application which is supposed to write new APN settings to a device however every time I run the application the new APN settings do not appear to be written to the device (the APN settings are totally blank after execution) I belive this may have something to do with a problem with InsertAPN() [shown below] however I'm unable to determine the root cause of the issue. P.S. Any debugging tips/questions are greatly appreciated. SOURCE SNIPPET: /* * Insert a new APN entry into

Content Resolver Query is not finding music on sd-card

我们两清 提交于 2019-12-24 03:51:31
问题 I have constructed a simple query to find music on the sdcard of the Android emulator. I am using Android Studio. I placed 3 songs on the sdcard using adb push. However, the query is not finding the music files. Here is an image of the files on the sdcard in the Music folder: Here is the code that I am using to perform the query: ContentResolver musicResolver = getContentResolver(); Uri musicUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; Cursor musicCursor = musicResolver.query(musicUri,

Android: “Cannot Resolve symbol 'addValueEventListener'” in Firebase

允我心安 提交于 2019-12-24 01:53:32
问题 I've tried importing a variety of Firebase packages to stop this error from occurring, but it still persists. I'm trying to do something along the lines of: firebase.addValueEventListener(new ValueEventListener() { but I'm consistently getting the error: Cannot Resolve symbol 'addValueEventListener' despite the fact I have ValueEventListener imported. (It might be important to note that ValueEventListener is displayed in the IDE as an unused import, even though I'm clearly attempting to use

How can make a FileProvider available to other applications?

心已入冬 提交于 2019-12-23 07:41:25
问题 Is it possible to have a FileProvider available to other applications ? manifest.xml ... <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.example.myapp.fileprovider" android:exported="true" android:grantUriPermissions="false" android:permission="com.example.filesvisible.permission.READ" > <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filespath" /> </provider> ... From the doc: false: The provider is not available