• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps App crashes after splash screen.Help

Hello.I made a application that adds by 10's and i decided for the first time to make a splash screen.For some reason the app crashes after the Splash screen.Idk if the problem is with the manifest or the java code.I really appreciate the help.

Starting point.Java
PHP:
package com.example.counter;



import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


public class Startingpoint extends Activity {

    int counter;
    Button add, sub;
    TextView display;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        counter = 0;
        add = (Button) findViewById(R.id.Btnadd);
        sub = (Button) findViewById(R.id.Btnsub);
        display = (TextView) findViewById(R.id.Tv1);
        
        add.setOnClickListener(new View.OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                counter += 10;
                display.setText("Current number is " + counter);
            }
        });
        
        sub.setOnClickListener(new View.OnClickListener() {
            
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                counter -= 10;
                display.setText("Current number is " + counter);
                
            }
        });
        
        
        }
    
    
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}
Splash.Java
PHP:
package com.example.counter;

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

public class Splash extends Activity {

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

}
Manifest
PHP:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.counter"
    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=".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=".startingPoint"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.counter.STARINGPOINT" />

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

</manifest>
 
Hi, Could you post your exception stack trace. By looking at the code I can hazard a guess though. Instead of using a new thread use a Handler (which acts like a scheduler on the main UI thread). In the current code, your activity Starting Point is being invoked from a non UI thread (non main thread) which I believe could be causing the issue. If you do need to have a new thread in the splash screen use runOnUIThread to post to the UI thread.
 
Upvote 0
Hi, Could you post your exception stack trace. By looking at the code I can hazard a guess though. Instead of using a new thread use a Handler (which acts like a scheduler on the main UI thread). In the current code, your activity Starting Point is being invoked from a non UI thread (non main thread) which I believe could be causing the issue. If you do need to have a new thread in the splash screen use runOnUIThread to post to the UI thread.

Im a begginer and i dont know what exception stack trace is.Could you tell me how i can get it.Thank you.
 
Upvote 0
No worries - a journey of a thousand miles still has to start with the first step. If you are using eclipse, check the logcat output for an exception stack (it will be in red). It will mention the reason why the app crashed. Logcat is one of the views that you should see towards the bottom panel in eclipse. Hope this helps. Use google for getting to use the eclipse and logcat if required.
 
Upvote 0
No worries - a journey of a thousand miles still has to start with the first step. If you are using eclipse, check the logcat output for an exception stack (it will be in red). It will mention the reason why the app crashed. Logcat is one of the views that you should see towards the bottom panel in eclipse. Hope this helps. Use google for getting to use the eclipse and logcat if required.


I see it and it says "com.example.counter.Splash$1.run(Splash.java:24)".Also when i double click it highlights "startActivity(startx);".
 
Upvote 0
Try:

Code:
Intent startx = new Intent (getBaseContext(), Startingpoint.class);

You shouldn't need the intent filter in your Startingpoint manifest entry (although it won't do any harm), but you do need to make sure the name attribute exactly matches your class name (e.g. it should be 'android:name=".Startingpoint"' and not 'android:name=".startingPoint"'.)
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones