0
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>
zholmes1
  • 539
  • 5
  • 21
  • Maybe you are missing some permissions in manifest ? Can't get anything else without more code. – mt0s Oct 09 '14 at 17:12
  • You don't need any permissions to start Activies do you? – zholmes1 Oct 09 '14 at 17:17
  • That's true but something is wrong in your manifest and I was just guessing. Please post all the code from the manifest file. – mt0s Oct 09 '14 at 17:21
  • It is probably SettingsActivity that needs some permission before it can run (if for example you try to modify a system setting) – x-code Oct 09 '14 at 17:40
  • I think service's name is wrong. You might missing a dot or the full package name. : . Can you try and change it ? I mean like or with the fully qualified name. – mt0s Oct 09 '14 at 18:31

2 Answers2

1

I think it is much more likely that your app/SettingsActivity has decided to go into the background/exit by the time that startActivity was invoked. Yes I am aware that the stacktrace shows it is occurring on the UI thread and so the Activity shouldn't be able to finish while that is occurring, but there appear to be some bugs in the support libraries that aren't handling the Activity/Fragment lifecycle very well is some edge cases.

I think your user hit one of these edge cases.

William
  • 20,150
  • 8
  • 49
  • 91
0

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>
Community
  • 1
  • 1
mt0s
  • 5,781
  • 10
  • 42
  • 53
  • Alright I made this change and I haven't seen that crash again... I'll tentatively mark this as a correct answer for now. – zholmes1 Oct 10 '14 at 06:11