Best code examples for Android Toast class (android.widget.Toast)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Toast class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android Toast examples from Open Source projects
This code example shows how to use the following methods: setDuration, setGravity, setView, show
103:	final Toast myToast = new Toast(mActivity); 
-
106:	myToast.setView(myView); 
107:	myToast.setDuration(Toast.LENGTH_SHORT); 
108:	myToast.setGravity(Gravity.BOTTOM | Gravity.CENTER, 0, 0); 
109:	myToast.show(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setDuration, setGravity, setView, show
94:	Toast toast = new Toast( mContext.getApplicationContext() ); 
-
96:	toast.setGravity( gravity, 0, 0 ); 
97:	toast.setDuration( duration ); 
98:	toast.setView( layout ); 
99:	toast.show(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: finish, startActivity, setClass, makeText
61:	Toast.makeText(context,message,Toast.LENGTH_LONG).show(); 
-
63:	Intent i = new Intent().setClass(context, TabWidget.class); 
64:	context.startActivity(i); 
-
66:	context.finish(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDuration, setView, show
27:	Toast toast = new Toast(this); 
28:	toast.setDuration(Toast.LENGTH_LONG); 
29:	toast.setView(toastLayout); 
30:	toast.show(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getResources, makeText
90:	final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; 
-
92:	* context.getResources().getDisplayMetrics().density); 
-
94:	Toast cheatSheet = Toast.makeText(context, text, Toast.LENGTH_SHORT); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: runOnUiThread, getString, makeText
83:	showToast( activity, activity.getString( resId, formatArgs ) ); 
-
104:	sToast = Toast.makeText( activity, message, Toast.LENGTH_SHORT ); 
-
124:	activity.runOnUiThread( sToastMessager ); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getXOffset, getYOffset, setGravity, show
113:	mToast.setGravity(Gravity.CENTER, mToast.getXOffset() / 2, mToast.getYOffset() / 2); 
114:	mToast.show(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: finish, makeText
208:	Toast.makeText(host, text, Toast.LENGTH_SHORT).show(); 
-
211:	host.finish(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getSharedPreferences, startActivity, makeText
83:	Editor editor = context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit(); 
-
91:	context.startActivity(accountIntent); 
-
93:	Toast.makeText(context, registration, Toast.LENGTH_LONG); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setText, show
308:	mToast.setText(context.getString(message)); 
309:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getString, makeText
23:	showToast(context, context.getString(stringResId), duration); 
-
30:	Toast toast = Toast.makeText(context, text, (duration== Duration.SHORT ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getString, makeText
28:	makeToast(context, context.getString(resId)); 
-
32:	Toast.makeText(context, message, Toast.LENGTH_LONG).show(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getString, makeText
82:	Toast.makeText(mActivity, error, Toast.LENGTH_SHORT).show(); 
-
91:	showError(mActivity.getString(resId)); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setDuration, setGravity, setView, show
88:	mToast.setView(mView); 
89:	mToast.setDuration(Toast.LENGTH_SHORT); 
90:	mToast.setGravity(Gravity.TOP, 0, 0); 
91:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getBroadcast, getSystemService, makeText
24:	Toast.makeText(context, "onDisabled():last widget instance removed", Toast.LENGTH_SHORT).show(); 
-
26:	PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0); 
27:	AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: cancel
31:	sToast.cancel(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: show
86:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setDuration, setGravity, setView, show
88:	mToast.setView(mView); 
89:	mToast.setDuration(Toast.LENGTH_SHORT); 
90:	mToast.setGravity(Gravity.TOP, 0, 0); 
91:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getPackageManager, makeText
91:	Toast.makeText(mContext, "Developer mode enabled", 
-
116:	PackageManager pm = mContext.getPackageManager(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getXOffset, getYOffset, setGravity, show
114:	mToast.setGravity(Gravity.CENTER, mToast.getXOffset() / 2, mToast.getYOffset() / 2); 
115:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getString, makeText
88:	String str = context.getString(prompt); 
-
93:	Toast toast = Toast.makeText(context, prompt, Toast.LENGTH_SHORT); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: cancel
31:	sToast.cancel(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: show
40:	toast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setText, show
43:	toast.setText(sText); 
44:	toast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: cancel, getView
112:	if ((tooltip != null) && (tooltip.getView().getParent() != null)) { 
113:	tooltip.cancel(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: startActivity, makeText
215:	context.startActivity(i); 
-
217:	Toast.makeText(context, ex.getMessage() + " for " + url, Toast.LENGTH_LONG).show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: cancel
73:	toast.cancel(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setDuration, setView, show
18:	Toast toast = new Toast(context); 
-
22:	toast.setView(toastLayout); 
23:	toast.setDuration(length); 
24:	toast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: show
61:	mToasts.put(id, t = Toast.makeText(this, id.intValue(), Toast.LENGTH_SHORT)); 
62:	t.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setText, show
99:	lastText.setText(text); 
-
101:	lastText.show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setDuration, setGravity, show
52:	mToast.setGravity(Gravity.CENTER, 0, 0); 
53:	mToast.setDuration(length); 
54:	mToast.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getSystemService, makeText
12:	Toast.makeText(context, "Don't panik but your time is up!!!!.", 
-
16:	.getSystemService(Context.VIBRATOR_SERVICE); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: cancel
31:	sToast.cancel(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setText, show
69:	toast.setText(msg); 
70:	toast.show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setText, show
69:	toast.setText(msg); 
70:	toast.show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: finish, makeText
54:	Toast.makeText(activity, "Your evil remote control has exploded! Now Astroboy is FREEEEEEEEEE!", Toast.LENGTH_LONG).show(); 
55:	activity.finish(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getSystemService, makeText
21:	PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); 
-
36:	Toast.makeText(context, msgStr, Toast.LENGTH_LONG).show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: startActivity, makeText
113:	Toast t = Toast 
-
120:	context.startActivity(new Intent("android.settings.LOCATION_SOURCE_SETTINGS")); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: startActivity, makeText
30:	activity.startActivity(dialIntent); 
-
32:	Toast.makeText(activity, 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getResources, makeText
59:	Toast.makeText(mMain, mMain.getResources().getString(mId), Toast.LENGTH_LONG).show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: startActivity, makeText
95:	this.a.startActivity(this.i); 
-
98:	Toast.makeText(this.a, "no activity found", Toast.LENGTH_LONG).show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: cancel
204:	t.cancel(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: cancel
204:	t.cancel(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setSpan, makeText
52:	Spannable text = new SpannableString("Italic green text in toast"); 
53:	text.setSpan(new StyleSpan(Typeface.ITALIC), 0, 18,  Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 
54:	text.setSpan(new ForegroundColorSpan(Color.GREEN), 0, 18,  Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 
55:	Toast.makeText(this, text, Toast.LENGTH_LONG).show(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: cancel, show
207:	toast.cancel(); 
208:	toast.show(); 
Full Snippet Info
6
CodeRank
Related Android Toast Questions & Answers:
See Code Examples for Android Toast Methods: