zholmes1 zholmes1 - 5 months ago 33
Android Question

SecurityException: "Unable to start activity Intent" when using a simple startActivity

startActivity(new Intent(this, SettingsActivity.class));


Got me an instance of this error for one of my users on 4.0:

java.lang.SecurityException: Not allowed to start activity Intent { cmp=co.bandicoot.ztrader/.activity.SettingsActivity }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1675)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1442)
at android.app.Activity.startActivityForResult(Activity.java:3474)
at android.app.Activity.startActivityForResult(Activity.java:3435)
at android.support.v4.app.FragmentActivity.startActivityForResult(SourceFile:839)
at android.app.Activity.startActivity(Activity.java:3677)
at android.app.Activity.startActivity(Activity.java:3645)
at co.bandicoot.ztrader.activity.MainActivity.onOptionsItemSelected(SourceFile:3446)
.....


Here is my manifest declaration for SettingsActivity:

<activity
android:name="co.bandicoot.ztrader.activity.SettingsActivity"
android:label="@string/action_settings"
android:parentActivityName="co.bandicoot.ztrader.activity.MainActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="co.bandicoot.ztrader.activity.MainActivity" />
</activity>


Any ideas?

Edit: Here's my full manifest. Is there anything wrong here? I'm looking at SettingsActivity and it doesn't seem like there's anything in there that might need additional permissions.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="co.bandicoot.ztrader"
android:versionCode="110"
android:versionName="3.5.2" >

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="20" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/Theme.Ztraderdarkactionbar" >
<receiver android:name=".TickerAlarm" >
</receiver>
<receiver android:name=".FastAlarm" >
</receiver>
<receiver android:name=".DownloadCurrencyPairsTask" >
</receiver>
<receiver android:name=".AutoStart" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" >
</action>
</intent-filter>
</receiver>

<service android:name="KillNotificationService" >
</service>

<activity
android:name="co.bandicoot.ztrader.activity.MainActivity"
android:configChanges="orientation"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:uiOptions="splitActionBarWhenNarrow"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="co.bandicoot.ztrader.activity.CreateKeyActivity"
android:label="@string/create_key"
android:parentActivityName="co.bandicoot.ztrader.activity.MainActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="co.bandicoot.ztrader.activity.MainActivity" />
</activity>
<activity
android:name="co.bandicoot.ztrader.activity.HistoryActivity"
android:label="@string/history"
android:parentActivityName="co.bandicoot.ztrader.activity.MainActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="co.bandicoot.ztrader.activity.MainActivity" />
</activity>
<activity
android:name="co.bandicoot.ztrader.activity.SettingsActivity"
android:label="@string/action_settings"
android:parentActivityName="co.bandicoot.ztrader.activity.MainActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="co.bandicoot.ztrader.activity.MainActivity" />
</activity>
<activity
android:name="co.bandicoot.ztrader.activity.ChartActivity"
android:label="@string/app_name"
android:parentActivityName="co.bandicoot.ztrader.activity.MainActivity"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="co.bandicoot.ztrader.activity.MainActivity" />
</activity>
<activity
android:name="co.bandicoot.ztrader.activity.ManagePairsActivity"
android:label="@string/pairs"
android:screenOrientation="portrait" >
</activity>
</application>

</manifest>

Answer

I wrote it as a comment but I'm adding it here to. From link :

android:name

The name of the Service subclass that implements the service. This should be a fully qualified class name (such as, "com.example.project.RoomService"). However, as a shorthand, if the first character of the name is a period (for example, ".RoomService"), it is appended to the package name specified in the element.

So try and change your service to :

 <service android:name=".KillNotificationService" >
    </service>