1. Are you ready for the Galaxy S20? Here is everything we know so far!

What's wrong with my code?

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

  1. bckc

    bckc Lurker
    Thread Starter

    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
     


  2. Calc

    Calc Member

    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);
     
Loading...
Similar Threads - What's wrong code
  1. Dulanja Senanayake
    Replies:
    2
    Views:
    238
  2. andrea salado
    Replies:
    2
    Views:
    214
  3. james_uk
    Replies:
    0
    Views:
    173
  4. Sammynacoletharpe
    Replies:
    3
    Views:
    175
  5. JohnJSal
    Replies:
    9
    Views:
    471
  6. Dannydet
    Replies:
    0
    Views:
    212
  7. dontpanicbobby
    Replies:
    4
    Views:
    394
  8. lovingdog
    Replies:
    1
    Views:
    1,040
  9. shakoc
    Replies:
    0
    Views:
    540
  10. Tyler2323
    Replies:
    5
    Views:
    1,609

Share This Page

Loading...