It's getting really annoying. I'm trying to show a simple toast and it will just not appear.
public class MainActivity extends Activity implements UserPromptDialogListener {
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
public ProgressDialog progressDialog;
public static String SELECTION_TYPE="type";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CharSequence text = "I am a toast sss";
Toast t1 = Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT);
t1.show();
Log.d("AAA", "After toast show");
}
//other methods
}
I have tried this
, MainActivity.this
, etc. but it does not seem to work.
Any help is appreciated.Thanks.
I just tested and this code and works fine in onCreate
, I see the Toast
right as the Activity
is created.
One way to trigger onCreate
:
Toast
.Another way to trigger onCreate
:
Activity
will be destroyed and recreated.This will ensure your Activity
goes through onCreate
and you see the Toast
. Tell me if either of those are working for you (they are for me).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With