Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is android:exported="true" required for internal use of content provider

I have defined a provider in my application manifest :

<provider
    android:authorities="com.example.myapp.provider"
    android:name="com.example.myapp.MyProvider">
</provider>

The provider is required only to be used within the application. But I get the below error when i try to run my activity :

Failed to find provider info..

But it works perfectly if i simply set the export attribute of the provider in the manifest :

android:exported="true" 

So my question is why is this required? Because, according to the documentation(http://developer.android.com/guide/topics/manifest/provider-element.html#exported), export is required only if the provider is to be available for other applications. Am i doing something wrong?

[Edit] : Suprisingly, the error has disappeared now even after removing the exported attribute, without making any other changes. I have no clue why it is working now. Probably some stupid mistake from my side. I leave this question open in hope of getting any clues as to what must have gone wrong.

[Edit] : I am facing this issue again with a receiver this time. So it was not a mistake from my side, as i assumed in my previous edit. I suspect something is wrong in the ADT build tool.

like image 841
faizal Avatar asked Jun 01 '14 07:06

faizal


People also ask

What is the use of Android exported true?

android:exported Whether or not the broadcast receiver can receive messages from sources outside its application — "true" if it can, and "false" if not. If "false", the only messages the broadcast receiver can receive are those sent by components of the same application or applications with the same user ID.

What does it mean Android exported?

android:exported. This element sets whether the activity can be launched by components of other applications: If " true ", the activity is accessible to any app, and is launchable by its exact class name.

What is exported true in activity?

The important part is android:exported="true" , this export tag determines "whether or not the activity can be launched by components of other applications". If your <activity> contains an <intent-filter> then this tag is set to true automatically, if it does not then it is set to false by default.

What is exported false in Android?

The exported tag prevents a (non-system) launcher from launching the activity. However, it is wrong to state that exported="false" stops the component from being started from anything that is not the application itself. This is particularly important when it comes to system manifest broadcasts (e.g. BOOT_COMPLETED ).


1 Answers

Make sure your <provider> tag is inside the <application>...</application> tags.

<application>
    ...
    <provider
        android:authorities="com.ingamedeo.databasetest.contentprovider"
        android:name=".db.ContentProviderDb"
        android:exported="false">            
    </provider>
</application>
like image 197
Amedeo Baragiola Avatar answered Oct 21 '22 14:10

Amedeo Baragiola