Brad Bass
Brad Bass

Reputation: 371

Android - Launcher does not have the permission to launch Intent

First off, I know this has been asked before and I have gone through many many posts regarding this. Unfortunately, my case seems to be a bit different. Most of the posts advised to remove the permission statement from application tag. This, unfortunately, does not help my situation, as I do not have permissions inside the application tag. I would very much appreciate any assistance.

Here is my AndroidManifest.xml:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jonasSoftware.blueharvest"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name="com.jonasSoftware.blueharvest.LoginActivity"
            android:label="@string/app_name"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.jonasSoftware.blueharvest.ChargeActivity"
            android:label="@string/title_activity_charge" >
        </activity>
        <activity
            android:name="com.google.zxing.client.android.CaptureActivity"
            android:configChanges="orientation|keyboardHidden"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:windowSoftInputMode="stateAlwaysHidden" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.google.zxing.client.android.SCAN" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
                android:name="com.jonasSoftware.blueharvest.HomeActivity"
                android:label="Home" >
        </activity>
        <activity
            android:name="com.jonasSoftware.blueharvest.ConfigActivity"
            android:label="Config" >
        </activity>
        <activity
            android:name="com.jonasSoftware.blueharvest.SettingsActivity"
            android:label="Settings" >
        </activity>
        <activity android:name=".WebServiceDemo" android:label="WebServiceDemo"/>
        <activity android:name=".UploadActivity"/>
        <activity android:name=".TransferActivity"/>
        <activity android:name=".ReceivePO"/>
        <activity android:name=".LoginActivity"/>
    </application>

</manifest>

The LoginActivity, if needed, is below. For testing purposes, it just starts the HomeActivity intent, with the majority of the code being commented out.

public class LoginActivity extends Activity {

    // JSON Response node names
    private static String KEY_SUCCESS = "success";
    private static String KEY_ERROR = "error";
    private static String KEY_ERROR_MSG = "error_msg";
    private static String KEY_UID = "uid";
    private static String KEY_NAME = "name";
    private static String KEY_USERNAME = "username";
    private static String KEY_CREATED_AT = "created_at";

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        setTitle("onas Scanner Login");

        final Button loginBtn = (Button) findViewById(R.id.btnLogin);
        final EditText loginUsername = (EditText) findViewById(R.id.loginUsername);
        final EditText loginPassword = (EditText) findViewById(R.id.loginPassword);
        final TextView loginErrorMsg = (TextView) findViewById(R.id.login_error);

        loginBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //do stuff
                String username = loginUsername.getText().toString();
                String password = loginPassword.getText().toString();

                Intent homeActivity = new Intent(getApplicationContext(), HomeActivity.class);
                homeActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(homeActivity);

            }
        });
    }
}

If any other information is required, please let me know.

Upvotes: 0

Views: 2775

Answers (1)

Brad Bass
Brad Bass

Reputation: 371

So as I was about to post this, I realized what my mistake was. Looking through the Manifest again I noticed something interesting. The application did not originally have the LoginActivity. When I added the LoginActivity, the following line was added to the Manifest.

<activity android:name=".LoginActivity"/>

I did not know this at the time and so just edited the original launcher activity, as seen below.

<activity
            android:name="com.jonasSoftware.blueharvest.LoginActivity"
            android:label="@string/app_name"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

the android:name= line had originally been "com.jonasSoftware.blueharvest.HomeActivity". So when I removed the extra line from the Manifest, everything started working again.

I hope this helps someone.

Brad.

Upvotes: 3

Related Questions