vamp658
vamp658

Reputation: 235

Android app installed but won't run

I started a new application and after settling my issues I started to make it. In the process I made a simple splash screen, but when I start the emulator it installs and won't run.

XML manifest

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

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

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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.pathfinderapprentice.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.pathfinderapprentice.MAIN_ACTIVITY" />

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

</manifest>

And the java class

package com.example.pathfinderapprentice;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class Splash extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        Thread timer = new Thread() {
            public void run() {
                try {
                    sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                } finally {
                    Intent openStartingPoint = new Intent(
                            "com.example.pathfinderapprentice.MAIN_ACTIVITY");
                    startActivity(openStartingPoint);
                }
            }
        };
        timer.start();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        finish();
    }
}

Thanks in advance

Upvotes: 0

Views: 305

Answers (3)

Inon Stelman
Inon Stelman

Reputation: 965

First of all, your manifest is wrong:

    <activity
        android:name="android.intent.action.MAIN"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.example.pathfinderapprentice.SPALSH" />

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

Should be

    <activity
        android:name=".Splash"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

On top of that, you shouldn't use a thread for this kind of timer, just use a Handler and then use either postDelayed() or postAtTime().

Upvotes: 0

Zohaib
Zohaib

Reputation: 2865

You have problem in your Manifest file.THis error happens when you have declared same activity twice in manifest or you have define two activities as main activity.

in activity tag you have define name as android:name="android.intent.action.MAIN"

you have to define name here like this

android:name="com.example.pathfinderapprentice.MainActivity"

and dont modify whats inside intent.

your activity tag should look like this

<application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Convert"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
</application>

Upvotes: 0

luxer
luxer

Reputation: 660

You haven't defined an Activity called

com.example.pathfinderapprentice.Splash

in your Manifest. Just correct this:

    <activity
        android:name="android.intent.action.MAIN"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.example.pathfinderapprentice.SPALSH" />

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

to

    <activity
        android:name="com.example.pathfinderapprentice.Splash"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

Upvotes: 2

Related Questions