List of usage examples for android.widget Toast LENGTH_LONG
int LENGTH_LONG
To view the source code for android.widget Toast LENGTH_LONG.
Click Source Link
From source file:Main.java
/** * Helper for creating toasts. You could call it a toaster. */// w ww . j a v a 2s . c o m public static void popToast(Context context, CharSequence text) { int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, text, duration); toast.show(); }
From source file:MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { Toast.makeText(this, Integer.toString(data.getIntExtra(REQUEST_RESULT, 0)), Toast.LENGTH_LONG).show(); }/*from www. j a v a 2s .c o m*/ }
From source file:com.nttec.everychan.ui.tabs.LocalHandler.java
public static void open(final String filename, final MainActivity activity) { TabModel model = getTabModel(filename, activity.getResources()); if (model == null) { Toast.makeText(activity, R.string.error_open_local, Toast.LENGTH_LONG).show(); return;//ww w.ja v a2 s .com } TabsAdapter tabsAdapter = activity.tabsAdapter; for (int i = 0; i < tabsAdapter.getCount(); ++i) { if (tabsAdapter.getItem(i).hash != null && tabsAdapter.getItem(i).hash.equals(model.hash)) { tabsAdapter.getItem(i).forceUpdate = true; tabsAdapter.setSelectedItem(i); return; } } tabsAdapter.add(model); tabsAdapter.setSelectedItemId(model.id); }
From source file:Main.java
/** * Save a media in the downloads directory and offer to open it with a third party application. * @param activity the activity/* w w w. ja va2s. c om*/ * @param savedMediaPath the media path * @param mimeType the media mime type. */ public static void openMedia(final Activity activity, final String savedMediaPath, final String mimeType) { if ((null != activity) && (null != savedMediaPath)) { activity.runOnUiThread(new Runnable() { @Override public void run() { try { File file = new File(savedMediaPath); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), mimeType); activity.startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(activity, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } catch (Exception e) { } } }); } }
From source file:MainActivity.java
public void showToast(View view) { LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.toast_custom, null); ((TextView) layout.findViewById(android.R.id.message)).setText("Custom Toast"); Toast toast = new Toast(this); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout);/* w ww .j a v a 2s .c o m*/ toast.show(); }
From source file:gov.nasa.arc.geocam.talk.UIUtils.java
/** * Display an exception at the log and to the user via {@link Toast}. * * @param context the context/*from ww w .j a v a2 s . c o m*/ * @param e the e * @param additionalMessage the additional message */ public static void displayException(Context context, Exception e, String additionalMessage) { Log.e("Talk", additionalMessage, e); StringBuilder sb = new StringBuilder(); if (additionalMessage != null) { sb.append(additionalMessage + ": "); } if (e.getLocalizedMessage() != null) { sb.append(e.getLocalizedMessage()); } Toast.makeText(context, sb.toString(), Toast.LENGTH_LONG).show(); }
From source file:com.liferay.tasks.callback.AddTaskCallback.java
@Override public void onFailure(Exception e) { String message = "Couldn't add task: " + e.getMessage(); Toast.makeText(_activity, message, Toast.LENGTH_LONG).show(); }
From source file:MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); PackageManager pm = getPackageManager(); List<ResolveInfo> activities = pm .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); if (activities.size() == 0) { findViewById(R.id.imageButton).setEnabled(false); Toast.makeText(this, "Speech Recognition Not Supported", Toast.LENGTH_LONG).show(); }/*from w w w .ja va 2 s . c om*/ SpeechRecognizer speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this); }
From source file:com.urucas.plugins.ToastPlugin.java
private void alert(String text, String duration, CallbackContext callbackContext) { Context context = this.cordova.getActivity(); int duration1; if (duration.toLowerCase().equals("long")) { duration1 = Toast.LENGTH_LONG; } else {//from w ww.j a v a 2 s . com duration1 = Toast.LENGTH_SHORT; } Toast toast = Toast.makeText(context, text, duration1); toast.show(); }
From source file:eltharis.wsn.showIDActivity.java
private String executeGET(int id) throws Exception { HttpClient httpclient = new DefaultHttpClient(); //tutaj jest podobnie jak w showAllActivity HttpResponse response = httpclient/* w ww. j ava2 s .c o m*/ .execute(new HttpGet("https://agile-depths-5530.herokuapp.com/usershow/" + Integer.toString(id))); StatusLine statusline = response.getStatusLine(); Toast toast = Toast.makeText(getApplicationContext(), "HTTP Response: " + Integer.toString(statusline.getStatusCode()), Toast.LENGTH_LONG); toast.show(); ByteArrayOutputStream out = new ByteArrayOutputStream(); response.getEntity().writeTo(out); String responseString = out.toString(); out.close(); return responseString; }