Using VoicemailContract Gives Permissions Error

2.7k views Asked by At

I am trying to use the VoicemailContract, but I keep getting a permissions error even though I am including the permision in my manifest. Can anyone shed some light on what's going on?

I get this error when trying to access the Voicemail provider:

java.lang.SecurityException: Permission denied for URI: content://com.android.voicemail/voicemail?source_package=com.google.android.apps.googlevoice
Requires com.android.voicemail.permission.READ_WRITE_ALL_VOICEMAIL permission.

I have added both the following permissions in my manifest:

<uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" />
<uses-permission android:name="com.android.voicemail.permission.READ_WRITE_ALL_VOICEMAIL" />

I also am not getting the following broadcast intent:

<receiver
    android:name=".VoicemailReceiver"
    android:exported="true" > 
    <intent-filter> 
        <action android:name="android.intent.action.NEW_VOICEMAIL" />
    </intent-filter> 
</receiver>

Any help would be appreciated. THANKS!

2

There are 2 answers

1
Camille Sévigny On BEST ANSWER

It looks like I'll be answering my own question again. I just found this little bit of information that is not included in the Google Documentation for the VoicemailContract:

http://developer.android.com/about/versions/android-4.0.html (scroll down to "Voicemail Provider")

Voicemail Provider

The new Voicemail Provider allows applications to add voicemails to the device, in order to present all the user's voicemails in a single visual presentation. For instance, it’s possible that a user has multiple voicemail sources, such as one from the phone’s service provider and others from VoIP or other alternative voice services. These apps can use the Voicemail Provider APIs to add their voicemails to the device. The built-in Phone application then presents all voicemails to the user in a unified presentation. Although the system’s Phone application is the only application that can read all the voicemails, each application that provides voicemails can read those that it has added to the system (but cannot read voicemails from other services).

Because the APIs currently do not allow third-party apps to read all the voicemails from the system, the only third-party apps that should use the voicemail APIs are those that have voicemail to deliver to the user.

The VoicemailContract class defines the content provider for the Voicemail Provder. The subclasses VoicemailContract.Voicemails and VoicemailContract.Status provide tables in which apps can insert voicemail data for storage on the device. For an example of a voicemail provider app, see the Voicemail Provider Demo.

So...basically, even though they have this new API (which is cool and useful), you would only have access to a Voicemail that your app inserted into the DB. You don't have access to any other voicemail that your device has.

I still am not sure if the Broadcast Intent should be fired for all apps on the device or only the system app(s), but since I am not receiving this broadcast, I can only assume that it's for the system app(s) only.

Feel free to confirm or deny this information. Thanks!

1
AJit On

i think you need to add your project package name i.e "content://com.android.voicemail/voicemail?source_package="+ ctx.getPackageName();