André DLC
André DLC

Reputation: 281

Activity android:exported="true" is not exported

In the preferences of my application, I call activity that handles special way certain parameters. So far it worked well. However, to create a trial version and a pro version, I just created a library with all the code and a new demo app that calls this library. Most of the application works except the call initiated by the declaration in the file preferences.xml. All statements are made ​​in the activity Manifest file of the demo version. I added the statement "android:exported ="true" to ClassesManager activity that is called by preferences but despite numerous attempts (by adding an intent-filter with various statements) I always get a crash with the message :

FATAL EXCEPTION: main
Process: be.adsoft.etimemo.demo, PID: 31250
java.lang.SecurityException: Permission   Denial: starting Intent { act=android.intent.action.VIEW cmp=be.adsoft.etimemo.base/.ClassesManager } from ProcessRecord{42fe8718 31250:be.adsoft.etimemo.demo/u0a182} (pid=31250, uid=10182) not exported from uid 10181
    at android.os.Parcel.readException(Parcel.java:1465)
    at android.os.Parcel.readException(Parcel.java:1419)

Extract of the demo app Manifest :

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/EtiHoloLight" >

    <!--  activity par défaut -->
    <activity
        android:name="be.adsoft.etimemo.base.ConnectScreen"
        android:configChanges="locale"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
   </activity>

    <!--  Déclaration de l'activité Préférences -->
    <activity 
        android:name="be.adsoft.etimemo.base.Preferences"
    android:label="@string/titre_preferences">
    </activity>

    ...

    <!--  Déclaration de l'activité ClasseManager -->
    <activity 
        android:name="be.adsoft.etimemo.base.ClassesManager"
        android:label="@string/txt_clmanager_titre_page"
    android:exported="true">            
    </activity>

</application>

Extract of the preferences.xml file :

<PreferenceScreen 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:robobunny="http://robobunny.com" >

<PreferenceCategory 
    android:title="@string/groupe_classe_title" 
    android:key="groupe_classe">

    <Preference
        android:title="@string/grkeyList_title"
        android:summary="@string/grkeyList_summary">
        <intent 
            android:action="android.intent.action.VIEW"
            android:targetPackage="be.adsoft.etimemo.base"
            android:targetClass="be.adsoft.etimemo.base.ClassesManager"
        />
    </Preference>

</PreferenceCategory>

Who can tell me what prevents this activity to be properly exported? NB: I've done several "clean" and "rebuild" to eliminate any worries in Eclipse.

Upvotes: 3

Views: 5686

Answers (1)

Andr&#233; DLC
Andr&#233; DLC

Reputation: 281

Having found the solution myself, I share it to save time to others: You should, at the declaration of intent in preferences, give as "package" the name of the application (.demo) and as name of activity the activity in the library (.base) :

    <Preference
        android:title="@string/grkeyList_title"
        android:summary="@string/grkeyList_summary">
        <intent 
            android:action="android.intent.action.VIEW"
            android:targetPackage="be.adsoft.etimemo.demo"
            android:targetClass="be.adsoft.etimemo.base.ClassesManager"                                 
        />
    </Preference>

Upvotes: 1

Related Questions