List of usage examples for android.widget Toast show
public void show()
From source file:com.miuidev.themebrowser.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.MenuThemeManager: final Intent intentThemeManager = new Intent("android.intent.action.MAIN"); intentThemeManager.setComponent(new ComponentName("com.android.thememanager", "com.android.thememanager.ThemeSettingsActivity")); try {/* w w w .j a v a 2s . c o m*/ startActivity(intentThemeManager); } catch (ActivityNotFoundException e) { Context context = getApplicationContext(); CharSequence text = getString(R.string.theme_manager_not_found); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } return true; case R.id.MenuAbout: displayAbout(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:net.reichholf.dreamdroid.activities.DreamDroidShareActivity.java
public void showToast(String text) { Toast toast = Toast.makeText(this, text, Toast.LENGTH_LONG); toast.show(); }
From source file:jp.co.brilliantservice.android.ric.command.SocketController.java
private void doPost(List<Buffer> buffers) { StringBuilder b = new StringBuilder(); for (int i = 0; i < buffers.size(); ++i) { Buffer e = buffers.get(i); if (i > 0) b.append('Z'); for (int j = e.offset; j < e.count; ++j) { b.append(String.format("%02X", e.buffer[j])); }/*from www . j a v a2 s. c om*/ } final String command = b.toString(); context.runOnUiThread(new Runnable() { public void run() { Toast toast = Toast.makeText(context, command.toString(), Toast.LENGTH_SHORT); toast.show(); } }); Runnable task = new Runnable() { public void run() { List<NameValuePair> nvps = new ArrayList<NameValuePair>(); Log.i("RIC", command); nvps.add(new BasicNameValuePair("c", command)); // try { // req.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); // } catch (UnsupportedEncodingException e1) { // } try { // final HttpResponse res = client.execute(req); // context.runOnUiThread(new Runnable() { // public void run() { // Toast toast = Toast.makeText(context, res // .getStatusLine().toString(), // Toast.LENGTH_SHORT); // toast.show(); // } // }); } catch (final Exception e) { context.runOnUiThread(new Runnable() { public void run() { Toast toast = Toast.makeText(context, e.getLocalizedMessage(), Toast.LENGTH_SHORT); toast.show(); } }); return; } } }; exec.execute(task); }
From source file:jp.co.brilliantservice.android.ric.command.HttpController.java
private void doPost(List<Buffer> buffers) { StringBuilder b = new StringBuilder(); for (int i = 0; i < buffers.size(); ++i) { Buffer e = buffers.get(i); if (i > 0) b.append('Z'); for (int j = e.offset; j < e.count; ++j) { b.append(String.format("%02X", e.buffer[j])); }/* ww w.ja va2s .co m*/ } final String command = b.toString(); context.runOnUiThread(new Runnable() { public void run() { Toast toast = Toast.makeText(context, command.toString(), Toast.LENGTH_SHORT); toast.show(); } }); Runnable task = new Runnable() { public void run() { DefaultHttpClient client = new DefaultHttpClient(); HttpPost req = new HttpPost(server); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); Log.i("RIC", command); nvps.add(new BasicNameValuePair("c", command)); try { req.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); } catch (UnsupportedEncodingException e1) { } try { final HttpResponse res = client.execute(req); context.runOnUiThread(new Runnable() { public void run() { Toast toast = Toast.makeText(context, res.getStatusLine().toString(), Toast.LENGTH_SHORT); toast.show(); } }); } catch (final Exception e) { context.runOnUiThread(new Runnable() { public void run() { Toast toast = Toast.makeText(context, e.getLocalizedMessage(), Toast.LENGTH_SHORT); toast.show(); } }); return; } } }; exec.execute(task); }
From source file:com.example.mysqltest.ScanBarcode.java
public void onActivityResult(int requestCode, int resultCode, Intent intent) { //retrieve scan result IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanningResult != null) { //we have a result scanContent = scanningResult.getContents(); //scanFormat = scanningResult.getFormatName(); codeBarang = scanContent;// w ww . j av a2s .c o m formatTxt.setText("Code Barang: " + scanContent); //contentTxt.setText("CONTENT: " + scanContent); new GetBarang().execute(); } else { Toast toast = Toast.makeText(getApplicationContext(), "No scan data received!", Toast.LENGTH_SHORT); toast.show(); } }
From source file:org.umit.icm.mobile.gui.BugReportActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bugreportactivity); activity = this; Report = (Button) findViewById(R.id.report); Reporter = (EditText) findViewById(R.id.Email); Description = (EditText) findViewById(R.id.description); Subject = (EditText) findViewById(R.id.subject); tracker = "Bug"; subject = ""; description = ""; priority = "Normal"; targetVersion = "0.1b"; httpclient = new DefaultHttpClient(); httppost = new HttpPost("http://dev.umitproject.org/projects/icm-mobile/issues.xml"); Report.setOnClickListener(new OnClickListener() { @Override//from w ww .j a va2 s . co m public void onClick(View arg0) { // TODO Auto-generated method stub try { if (Subject.getText().toString().equalsIgnoreCase("")) { String text = getString(R.string.bug_subject); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(getApplicationContext(), text, duration); toast.show(); } else if (Description.getText().toString().equalsIgnoreCase("")) { String text = getString(R.string.bug_describe); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(getApplicationContext(), text, duration); toast.show(); } else { reporter = Reporter.getText().toString(); subject = getString(R.string.bug_crash) + Subject.getText().toString(); if (reporter.equalsIgnoreCase("")) { description = getString(R.string.description) + " " + Description.getText().toString(); } else { description = getString(R.string.from) + " " + reporter + "\n" + getString(R.string.description) + " " + Description.getText().toString(); } String XML = "<issue>" + "<tracker>" + tracker + "</tracker>" + "<subject>" + subject + "</subject>" + "<description>" + description + "</description>" + "<priority>" + priority + "</priority>" + "<target_version>" + targetVersion + "</target_version>" + "</issue>"; new Background().execute(XML); } } catch (Exception e) { // TODO Auto-generated catch block Show.Error(activity, e.toString()); } } }); }
From source file:edu.cwru.apo.Contract.java
public void onRestRequestComplete(Methods method, JSONObject result) { if (method == Methods.getContract) { if (result != null) { try { String requestStatus = result.getString("requestStatus"); if (requestStatus.compareTo("success") == 0) { String contract = ""; contract += "Status: " + result.getString("status") + "\n"; contract += "Dues: " + result.getString("dues") + "\n\n"; contract += "Chapter Attendance: \n"; contract += "Attended: " + result.getDouble("chaptersAttended") + "\n"; contract += "Required: " + result.getDouble("chaptersRequired") + "\n\n"; contract += "Pledge Attendance: \n"; contract += "Attended: " + result.getDouble("pledgeAttended") + "\n"; contract += "Required: " + result.getDouble("pledgeRequired") + "\n\n"; contract += "Hours:\n"; contract += "Hours towards contract: " + result.getDouble("contractHours") + "/" + result.getDouble("contractHoursRequired") + "\n"; contract += "Inside Hours: " + result.getDouble("in") + "/" + result.getDouble("inRequired") + "\n"; contract += "Outside Hours: " + result.getDouble("out") + "\n"; contract += "Total semester Hours: " + result.getDouble("totalHours"); text.setText(contract); } else if (requestStatus.compareTo("timestamp invalid") == 0) { Toast msg = Toast.makeText(getApplicationContext(), "Invalid timestamp. Please try again.", Toast.LENGTH_LONG); msg.show(); } else if (requestStatus.compareTo("HMAC invalid") == 0) { Auth.loggedIn = false; Toast msg = Toast.makeText(getApplicationContext(), "You have been logged out by the server. Please log in again.", Toast.LENGTH_LONG); msg.show();/* w ww . j av a 2 s .c om*/ finish(); } else if (requestStatus.compareTo("no contract") == 0) { Toast msg = Toast.makeText(getApplicationContext(), "You have not signed a contract.", Toast.LENGTH_LONG); msg.show(); } else { Toast msg = Toast.makeText(getApplicationContext(), "Invalid requestStatus", Toast.LENGTH_LONG); msg.show(); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
From source file:br.ufsc.das.gtscted.shibbauth.SPSelectionActivity.java
/** Called when the activity is first created. */ @Override/*from w w w . j a va2 s. c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sp_selection); nextButton = (Button) findViewById(R.id.nextButton); exitButton = (Button) findViewById(R.id.exitButton); spEditText = (EditText) findViewById(R.id.spUrlEditText); //SP para testes spEditText.setText("https://sp.ufrgs.br/chimarrao/"); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String serviceUrl = spEditText.getText().toString(); try { Connection connection = new Connection(); String[] getResponseAndEndpoint = connection.httpGetWithEndpoint(serviceUrl); String wayfLocation = getResponseAndEndpoint[0]; String responseBody = getResponseAndEndpoint[1]; Bundle bundle = new Bundle(); bundle.putString("html_source", responseBody); bundle.putString("wayf_location", wayfLocation); bundle.putSerializable("cookie", connection.getSerializableCookie(0)); Intent newIntent = new Intent(SPSelectionActivity.this, ShibAuthenticationActivity.class); newIntent.putExtras(bundle); startActivity(newIntent); } catch (KeyManagementException e) { String message = "KeyManagementException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (NoSuchAlgorithmException e) { String message = "NoSuchAlgorithmException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (KeyStoreException e) { String message = "KeyStoreException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (UnrecoverableKeyException e) { String message = "UnrecoverableKeyException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (ClientProtocolException e) { String message = "ClientProtocolException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (IOException e) { String message = "IOException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (Exception e) { String message = "Exception"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } } }); exitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); }
From source file:br.ufrn.dimap.pubshare.download.service.DownloaderService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Toast toast = Toast.makeText(this, "Starting download. see action bar to see the progress.", Toast.LENGTH_SHORT);/*from ww w .jav a2s. c o m*/ toast.setGravity(Gravity.BOTTOM | Gravity.CENTER, 0, 0); toast.show(); return super.onStartCommand(intent, flags, startId); }
From source file:com.facebook.android.FriendsList.java
public void showToast(final String msg) { mHandler.post(new Runnable() { @Override//from www . j a v a 2 s. c o m public void run() { Toast toast = Toast.makeText(FriendsList.this, msg, Toast.LENGTH_LONG); toast.show(); } }); }