-6

Java:

package com.example.test1;

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

public class Splash extends Activity {

@Override
protected void onCreate(Bundle TravisLoveBacon) {
    // TODO Auto-generated method stub
    super.onCreate(TravisLoveBacon);
    setContentView(R.layout.splash);}
    Thread timer = new Thread(){
        public void run(){
            try{
                sleep(5000);

            } catch (InterruptedException e){
                e.printStackTrace();
                }finally{   
                    Intent openStartingPoint = new intent ("com.example.test1.MainActivity");
                    startActivity(openStartingPoint);
                }

           }
    }


;
timer.start(); 

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="@drawable/splash_background">


</LinearLayout>

Edit: Terribly sorry! Was posting in a haste and completely forgot to list the errors.

timer.start(); - Syntax error, insert "}" to complete ClassBody - Syntax error on token "start", Identifier expected after this token

I've been staring at my code for an hour and can't find the issue. I just know the bug is some stupid syntax error thats staring right back at me.

Any help appreciated!

user3355817
  • 121
  • 1
  • 1
  • 6
  • 8
    I wanted to edit the title to something meaningful but...you haven't told us **anything** about the problem! – codeMagic Mar 10 '14 at 20:00
  • Is the `}` bracket after `setContentView(R.layout.splash);` intented? – micha Mar 10 '14 at 20:01
  • You cannot start an activity from outside the Main thread. Check this answer http://stackoverflow.com/questions/6274653/how-to-start-an-activity-from-a-thread-class-in-android – Marcelo Mar 10 '14 at 20:05

2 Answers2

2

Delete the ; before timer.start(); and delete the } at the end of the setContentView(R.layout.splash);} line.

Smutje
  • 17,733
  • 4
  • 24
  • 41
  • It's not really a problem; it ends the method, so the rest of the program runs when the class is created. – Ypnypn Mar 10 '14 at 20:05
0

Add a closing braces (}) at the end of the program to end the class.

Ypnypn
  • 933
  • 1
  • 8
  • 21