1. Download our Official Android App: Forums for Android!

Apps What's wrong with my code?

Discussion in 'Android Development' started by bckc, Aug 4, 2013.

  1. bckc

    bckc Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Aug 4, 2013

    Aug 4, 2013
    1
    0
    5
    Hi guys,

    Can someone please tell me what I've done wrong here?:

    Manifest snippet:
    Code (Text):
    1.  
    2.     <application
    3.         android:allowBackup="true"
    4.         android:icon="@drawable/ic_launcher"
    5.         android:label="@string/app_name"
    6.         android:theme="@style/AppTheme" >
    7.         <activity
    8.             android:name=".Splash"
    9.             android:label="@string/app_name" >
    10.             <intent-filter>
    11.                 <action android:name="com.bradley.appname.Splash" />
    12.  
    13.                 <category android:name="android.intent.category.LAUNCHER" />
    14.             </intent-filter>
    15.         </activity>
    16.        
    17.       <activity
    18.             android:name=".mainActivity"
    19.             android:label="@string/app_name" >
    20.             <intent-filter>
    21.                 <action android:name="com.bradley.appname.MainActivity" />
    22.  
    23.                 <category android:name="android.intent.category.DEFAULT" />
    24.             </intent-filter>
    25.         </activity>
    26.        
    27.        
    28.     </application>
    29.  
    My java snippet:
    Code (Text):
    1.  
    2.         Thread timer = new Thread(){
    3.            
    4.             public void run(){
    5.                
    6.                 try{
    7.                     sleep(4000);        
    8.                 }catch(InterruptedException e){
    9.                     e.printStackTrace();
    10.                 }finally{
    11.                     Intent openMain = new Intent("com.bradley.appname.MainActivity");
    12.  
    13.                     startActivity(openMain);
    14.                 }
    15.                
    16.             }
    17.         };
    18.         timer.start();
    19.  
    When the splashscreen starts it waits 4 seconds then says "app name has been forced to close"

    Bckc
     

    Advertisement

  2. Calc

    Calc Member
    Rank:
    None
    Points:
    36
    Posts:
    65
    Joined:
    Aug 4, 2013

    In this cases you just need to look at the LOGCAT and see what went wrong...

    In you case, Android can't find MainActivity, this is the correct syntax.

    Intent openMain = new Intent(context, MainActivity.class);
     

Share This Page

Loading...