0

I just splitted my App in a Pro and Free version. Therefore I made my application a library and created two new projects. The free version kept the namespace "com.mxp.time" and the pro version got the namespace "com.sourcecastle.mytime". So the free version has the same namespace as my library. Everything works fine except when I start a activity from preference activity in the pro version. There I get:

Permission Denial: starting Intent { act=android.intent.action.VIEW cmp=com.mxp.time/.DataManagementActivity } from ProcessRecord{45461048 30784:com.sourcecastle.mytime/u0a10012} (pid=30784, uid=10012) not exported from uid 10013

My Preferences.xml looks like:

  <!-- datamanagement -->
<PreferenceCategory
    android:key="datamanagement_category"
    android:title="@string/settings_datamanagement_title" >
    <Preference
        android:summary="@string/settings_datamanagement_pref_message"
        android:title="@string/settings_datamanagement_pref_title" >
        <intent
            android:action="android.intent.action.VIEW"
            android:targetClass="com.mxp.time.DataManagementActivity"
            android:targetPackage="com.mxp.time" />
    </Preference>
</PreferenceCategory>

And my manifest:

 <activity
        android:name="com.mxp.time.DataManagementActivity"
        android:exported="true"
        android:label="@string/datamanagement_title" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
        </intent-filter>
    </activity>

I already set

“android:exported="true"

in my manifest but I still get an exception.

Additionally I have a general question: Where should I define my activities now? In the library or in the real application? I tried to remove all permissions and activities from my library project and my app keeps working. But since I got this problem I ask myself if this isn’t a security issue because registering my activities in my application only lets me override settings like “exported”…

Can anyone help me understand that?

UPDATE:

This seems to work:

  <!-- datamanagement -->
<PreferenceCategory
    android:key="datamanagement_category"
    android:title="@string/settings_datamanagement_title" >

    <!-- <Preference -->
    <!-- android:summary="@string/settings_datamanagement_pref_message" -->
    <!-- android:title="@string/settings_datamanagement_pref_title" > -->
    <!-- <intent -->
    <!-- android:action="android.intent.action.VIEW" -->
    <!-- android:targetClass="com.mxp.time.DataManagementActivity" -->
    <!-- android:targetPackage="com.mxp.time" /> -->
    <!-- </Preference> -->

    <PreferenceScreen
        android:summary="@string/settings_datamanagement_pref_message"
        android:title="@string/settings_datamanagement_pref_title" >
        <intent android:action="com.mxp.time.DataManagementActivity" />
    </PreferenceScreen>
</PreferenceCategory>

and:

 <activity
        android:name="com.mxp.time.DataManagementActivity"
        android:exported="true"
        android:label="@string/datamanagement_title" >
        <intent-filter>
            <action android:name="com.mxp.time.DataManagementActivity" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

And my other question is ansered here: Android Library Manifest vs. App Manifest

Community
  • 1
  • 1
stefan
  • 1,336
  • 3
  • 21
  • 46
  • Did you find a solution for this problem? I have the same problem for one of my activity althought I'm using libraries since years... – L. G. Oct 03 '14 at 15:42

1 Answers1

1

Declare your Activity that way:

 <activity
        android:name="com.sourcecastle.commons.activity.DataManagementActivity"
        android:exported="true"
        android:label="@string/datamanagement_title" >
        <intent-filter>
            <action android:name="com.sourcecastle.commons.activity.DataManagementActivity" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

In preferences.xml do it the following way:

 <PreferenceCategory
    android:key="datamanagement_category"
    android:title="@string/settings_datamanagement_title" >
    <PreferenceScreen
        android:summary="@string/settings_datamanagement_message"
        android:title="@string/settings_datamanagement_title" >
        <intent android:action="com.sourcecastle.commons.activity.DataManagementActivity" />
    </PreferenceScreen>
</PreferenceCategory>

Cheers, Stefan

stefan
  • 1,336
  • 3
  • 21
  • 46