0

Well basically, I can't get my toast to appear on screen in my application, I have copied the toast code into a different app and the code works fine, just for some reason I can't seem to get it to work in this one. I have stripped my application back to just the splash screen that doesnt do anything but call the toast in the onCreate method but still nothing. I have tried everything I can think of. Could someone please tell me whats wrong with it? Any help is greatly appreciated.

public class Splash extends Activity{

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash_layout);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

        Toast t1 = Toast.makeText(this, "hello world", Toast.LENGTH_LONG);
        t1.show();

    }//end onCreate     
} // end splash

The manifest is given below in case that is useful to anyone, the extra activities are launched from the main menu but ive cut the intent that starts the main menu out of the splash acitivity to try and make it simpler to figure out whats wrong

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.example.bluetoothdms"
     android:versionCode="1"
      android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" 
    android:largeHeap="true">
    <activity
        android:name="com.example.bluetoothdms.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="com.example.bluetoothdms.MainMenu"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.example.bluetoothdms.Bluetooth_Content"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.example.bluetoothdms.DMS_Content"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.example.bluetoothdms.FAQ"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.example.bluetoothdms.File_Opener">
    </activity>
</application>

10
  • 10
    Broken toaster? Mar 27, 2013 at 13:57
  • Can you make a toast within the onCreate since it is not yet in the visible stage of the app/fragment lifecycle?
    – TronicZomB
    Mar 27, 2013 at 14:00
  • 1
    yes you can tronic because I called a toast in the oncreate of another app and it worked fine, i put it there to make it simpler, it doesnt work in on click methods or anywhere else i put it in this app either Mar 27, 2013 at 14:04
  • Hmm... intriguing. For me works... with the EXACT syntax as you used. This looks like an Eclipse issue. Try a Project -> Clean
    – sebster
    Mar 27, 2013 at 14:27
  • just tried it and nothing, is it possible the manifest or xml layout file could be blocking the toast? Mar 27, 2013 at 14:32

1 Answer 1

0

instantiate Toast with

Toast t1 = new Toast(context);
t1.makeText(....);
t1.show()

or use

Toast.makeText(...).show();
1
  • tried both ways you described already and nothing, ive tried everything Mar 27, 2013 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.