-1

My splash screen (splash.java) works fine , it appear for 5 sec when I call it Launcher in Android Manifest , but when i fix it as Default in Android Manifest and run it through List Activity (Menu.java) , it run for 5sec and then instead of going back to Menu.java it crashes with run time error . I want it to appear for 5 sec and then go back to the menu.java.

The manifest in which it not work for 5 sec but application crash run time after 5 sec (Unfortunately your application has stopped)

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

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name=".splash"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="com.example.hello.SPLASH" />

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

This splash.java

protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity2);
        tone = MediaPlayer.create(splash.this, R.raw.songg);
        tone.start();
        Thread haai = new Thread()
        {
            public void run()
            {
                try
                {
                    sleep(5000);
                }
                catch (InterruptedException e)
                {
                    e.printStackTrace();
                }
                finally 
                {
                    Intent first = new Intent("com.example.hello.Menu");
                    startActivity(first);
                }
            }       
        };
        haai.start();
    }

Error log:

E/AndroidRuntime(25707): FATAL EXCEPTION: Thread-30562
E/AndroidRuntime(25707): Process: com.example.hello, PID: 25707
E/AndroidRuntime(25707): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.hello.Menu }
E/AndroidRuntime(25707):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1672)
E/AndroidRuntime(25707):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1442)
E/AndroidRuntime(25707):    at android.app.Activity.startActivityForResult(Activity.java:3511)
E/AndroidRuntime(25707):    at android.app.Activity.startActivityForResult(Activity.java:3472)
E/AndroidRuntime(25707):    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
E/AndroidRuntime(25707):    at android.app.Activity.startActivity(Activity.java:3714)
E/AndroidRuntime(25707):    at android.app.Activity.startActivity(Activity.java:3682)
E/AndroidRuntime(25707):    at com.example.hello.splash$1.run(splash.java:36)

I am not satisfied with my own answer because i am in learning stage so waiting for better answer with explanation of its working and problem.

2
  • Can you post the error log
    – Psypher
    Mar 23, 2015 at 23:15
  • I update my error log
    – ARG
    Mar 23, 2015 at 23:24

4 Answers 4

3

ActivityNotFoundException: No

Because not Activity found with com.example.hello.MENU action in manifest.

To fix issue,use com.example.hello.MENU action string for Menu Activity. like:

<activity
    android:name=".Menu"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="com.example.hello.MENU" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

Or you can start Activity using target Activity class name :

Intent intent=new Intent (splash.this,Menu.class);
splash.this.startActivity(intent);
7
  • I changed the intent filter as you guided and change <action android:name="android.intent.action.MAIN" /> to <action android:name="com.example.hello.MENU" /> but now its not even showing the apk , and second part is missing class after new
    – ARG
    Mar 24, 2015 at 1:06
  • and why its not showing issue if i make .splash as Main Launcher
    – ARG
    Mar 24, 2015 at 1:21
  • @ARG: remove <category android:name="android.intent.category.LAUNCHER" from Menu activity tag Mar 24, 2015 at 1:29
  • then application is not even opening , which should be launcher then
    – ARG
    Mar 24, 2015 at 1:36
  • @ARG: add <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> in android:name=".splash" Mar 24, 2015 at 1:38
0

The problem is in the manifest you have set the activity name .Menu whereas in the java code you have set it as MENU(uppercase).

<activity
    android:name=".Menu" <---- activity name as .Menu
    android:label="@string/app_name" >

In java code as:

Intent first = new Intent("com.example.hello.MENU")<---.MENU- its all uppercase

Change it in java code as below to fix your problem:

Intent first = new Intent("com.example.hello.Menu");
startActivity(first);
5
  • same error that unfortunately your app has stopped , when splash screen finish after 5 sec
    – ARG
    Mar 24, 2015 at 1:26
  • Post the new error logs, before that just try chaging <action android:name="com.example.hello.SPLASH" /> to <action android:name="com.example.hello.splash" />
    – Psypher
    Mar 24, 2015 at 1:31
  • error is in finding .menu , .splash work fine and application not break when i make .splash as MAIN LAUNCHER , I tried that above of changing SPLASH to splash but it doesnt work as well
    – ARG
    Mar 24, 2015 at 1:33
  • You might have not corrected the activity name to .Menu either in java code or in the AndroidManifest.xml as I mentioned above
    – Psypher
    Mar 24, 2015 at 1:43
  • As i said it works if i make .splash as launcher as .Menu as Default
    – ARG
    Mar 24, 2015 at 1:45
0

I find the answer , its simple but I use the other way but still I don't find why the program works fine when .splash make as Main and LAUNCHER , but when make .Menu as Main and LAUNCHER program run but when I select splash from Menu List it run for 5 seconds then instead of going back to Menu again it crashes with runtime error . I changed the .splash code to the below code and it works but as I am new to android I don't know why the last way was not working.

public void run()
            {
                try
                {
                    sleep(5000);
                }
                catch (InterruptedException e)
                {
                    e.printStackTrace();
                }
                finally 
                {
                    try
                    {
                    Class ourclass = Class.forName("com.example.hello.Menu");
                    Intent myclass = new Intent(splash.this , ourclass);
                    startActivity(myclass);
                    }
                    catch(ClassNotFoundException e)
                    {
                        e.printStackTrace();
                    }

                }
            }       

I didn't change anything from Android Manifest

2
  • So, the code above works with Menu as Launcher + Main and Splash as Default?
    – Vikram
    Mar 30, 2015 at 3:09
  • yes but why its not working the other way and in this method sometime its just look like menu screen appear twice like you have to press back button twice , but why not the other method and whats the difference
    – ARG
    Mar 30, 2015 at 12:01
0

The problem is you declared intent action is .SPLASH but you create action is .MENU
change

Intent first = new Intent("com.example.hello.MENU");
                   startActivity(first);

to

Intent first = new Intent("com.example.hello.SPALSH");
                   startActivity(first);

or change your manifest like this

<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>
    <activity
        android:name=".Menu"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.example.hello.MENU" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
3
  • I did but still crash problem
    – ARG
    Apr 2, 2015 at 16:05
  • sorry, I was wrong with android:name please see my edit Apr 3, 2015 at 0:20
  • 1
    I dont want that when my application starts then splash screen appears , i want that menu appear first
    – ARG
    Apr 3, 2015 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.