Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Like Tree1Likes
  • 1 Post By Nitrosolid

test: Reply
 
LinkBack Thread Tools
Old April 1st, 2013, 02:21 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Aug 2012
Location: USA
Gender: Male
Posts: 9
 
Device(s): Samsung Galaxy S wifi 5.0 (Galaxy Player)
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 Code:
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 addsub;
    
TextView display;
    
    @
Override
    
protected void onCreate(Bundle savedInstanceState) {
        
super.onCreate(savedInstanceState);
        
setContentView(R.layout.main);
        
        
counter 0;
        
add = (ButtonfindViewById(R.id.Btnadd);
        
sub = (ButtonfindViewById(R.id.Btnsub);
        
display = (TextViewfindViewById(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.mainmenu);
        return 
true;
    }


Splash.Java
PHP Code:
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 Code:
<?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>

Advertisements
Nitrosolid is offline  
Reply With Quote
sponsored links
Old April 1st, 2013, 05:16 PM   #2 (permalink)
New Member
 
Join Date: Mar 2013
Posts: 7
 
Device(s):
Carrier: Not Provided

Thanks: 4
Thanked 0 Times in 0 Posts
Default

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.
magi_apps is offline  
Reply With Quote
Old April 1st, 2013, 06:12 PM   #3 (permalink)
New Member
Thread Author (OP)
 
Join Date: Aug 2012
Location: USA
Gender: Male
Posts: 9
 
Device(s): Samsung Galaxy S wifi 5.0 (Galaxy Player)
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by magi_apps View Post
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.
Nitrosolid is offline  
Reply With Quote
Old April 1st, 2013, 06:37 PM   #4 (permalink)
New Member
 
Join Date: Mar 2013
Posts: 7
 
Device(s):
Carrier: Not Provided

Thanks: 4
Thanked 0 Times in 0 Posts
Default

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.
magi_apps is offline  
Reply With Quote
Old April 1st, 2013, 09:24 PM   #5 (permalink)
New Member
Thread Author (OP)
 
Join Date: Aug 2012
Location: USA
Gender: Male
Posts: 9
 
Device(s): Samsung Galaxy S wifi 5.0 (Galaxy Player)
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by magi_apps View Post
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);".
GeorgeN likes this.
Nitrosolid is offline  
Reply With Quote
Old April 2nd, 2013, 07:11 PM   #6 (permalink)
Junior Member
 
Join Date: Dec 2012
Posts: 16
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default

hi i noticed this line in your manifest

<action android:name="com.example.counter.STARINGPOINT" />

if im not mistaken you maybe missing a "T" ie starTingpoint
DR doggy is offline  
Reply With Quote
Old April 3rd, 2013, 01:41 AM   #7 (permalink)
Member
 
Join Date: Apr 2012
Location: London
Posts: 101
 
Device(s): ZTE Skate, Ainol Novo7 Aurora
Carrier: Not Provided

Thanks: 2
Thanked 24 Times in 23 Posts
Default

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"'.)
GeorgeN is offline  
Reply With Quote
Reply
Tags
android, crash, splash


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 01:51 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.