List of usage examples for android.widget Toast LENGTH_SHORT
int LENGTH_SHORT
To view the source code for android.widget Toast LENGTH_SHORT.
Click Source Link
From source file:tcc.iesgo.activity.ClientMapActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try {//from w w w. j a va 2 s .c o m init(); } catch (Exception e) { Toast.makeText(ClientMapActivity.this, getString(R.string.login_error_connection), Toast.LENGTH_SHORT) .show(); } }
From source file:com.manning.androidhacks.hack009.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/* ww w . j a va2s . c om*/ // get the current date final Calendar c = Calendar.getInstance(); mYear = c.get(Calendar.YEAR); mMonth = c.get(Calendar.MONTH); mDay = c.get(Calendar.DAY_OF_MONTH); mDateSetListener = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Toast.makeText(MainActivity.this, getString(R.string.picked_date_format, monthOfYear, dayOfMonth, year), Toast.LENGTH_SHORT) .show(); } }; findViewById(R.id.details_date).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDialog(DATE_DIALOG_ID); } }); }
From source file:com.imalu.alyou.activity.RegisterActivity.java
/** * //ww w . jav a2 s . co m * * @param view */ public void register(View view) { final String pwd = passwordEditText.getText().toString().trim(); String confirm_pwd = confirmPwdEditText.getText().toString().trim(); if (TextUtils.isEmpty(pwd)) { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); passwordEditText.requestFocus(); return; } else if (TextUtils.isEmpty(confirm_pwd)) { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); confirmPwdEditText.requestFocus(); return; } else if (!pwd.equals(confirm_pwd)) { Toast.makeText(this, "????", Toast.LENGTH_SHORT).show(); return; } RegisterRequest registerReq = new RegisterRequest(); registerReq.setPassword(pwd); registerReq.setUsername(username); NetManager.execute(NetManager.REGISTER_REQUEST_OPERATION, registerReq, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { //pd.dismiss(); Log.e("login_check", " response:" + response.toString()); //Toast.makeText(getApplicationContext(), ": " + , 0).show(); //RegisterResponse regResp = (RegisterResponse)response; // ????? //AlUApplication.getInstance().setUserName(username); //AlUApplication.getInstance().setPassword(password); /*runOnUiThread(new Runnable() { public void run() { pd.setMessage("???..."); } });*/ try { RegisterResponse regResp = new RegisterResponse(); regResp.setJsonObject(response); Log.e("AAAAAAAAAA", "" + regResp.getCode()); if (regResp.getCode()) { Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), ": " + regResp.getInfo(), Toast.LENGTH_SHORT).show(); } // ** ?logout?? // ** manually load all local groups and // conversations in case we are auto login //EMGroupManager.getInstance().loadAllGroups(); //EMChatManager.getInstance().loadAllConversations(); // demo??????username?? /*List<String> usernames = EMContactManager.getInstance().getContactUserNames(); EMLog.d("roster", "contacts size: " + usernames.size()); for (String username : usernames) { User user = new User(); user.setUsername(username); setUserHearder(username, user); userlist.put(username, user); }*/ /*Map<String, User> userlist = new HashMap<String, User>(); // user"" User newFriends = new User(); newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME); newFriends.setNick(""); newFriends.setHeader(""); userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends); // "?" User groupUser = new User(); groupUser.setUsername(Constant.GROUP_USERNAME); groupUser.setNick("?"); groupUser.setHeader(""); userlist.put(Constant.GROUP_USERNAME, groupUser);*/ // //AlUApplication.getInstance().setContactList(userlist); // db //UserDao dao = new UserDao(LoginActivity.this); //List<User> users = new ArrayList<User>(userlist.values()); //dao.saveContactList(users); // ??(??groupidgroupname????members),sdkdb //EMGroupManager.getInstance().getGroupsFromServer();*/ } catch (Exception e) { Toast.makeText(getApplicationContext(), ": " + e.getMessage(), Toast.LENGTH_SHORT) .show(); //e.printStackTrace(); } Log.e("login_check", "1111111111111111111"); //?nickname ios?nick //boolean updatenick = EMChatManager.getInstance().updateCurrentUserNick(AlUApplication.currentUserNick); //if (!updatenick) { // EMLog.e("LoginActivity", "update current user nick fail"); //} //if (!LoginActivity.this.isFinishing()) //pd.dismiss(); // ? startActivity(new Intent(RegisterActivity.this, LoginActivity.class)); finish(); } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject jsonObj) { // Log.e("register", throwable.getMessage()); finish(); } @Override public void onFailure(int statusCode, Header[] headers, final String responseString, Throwable throwable) { runOnUiThread(new Runnable() { public void run() { //pd.dismiss(); //Toast.makeText(getApplicationContext(), ": " + responseString, 0).show(); Log.e("register", responseString); finish(); } }); } }); // if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) { final ProgressDialog pd = new ProgressDialog(this); pd.setMessage("..."); pd.show(); new Thread(new Runnable() { public void run() { try { // sdk EMChatManager.getInstance().createAccountOnServer(username, pwd); runOnUiThread(new Runnable() { public void run() { if (!RegisterActivity.this.isFinishing()) pd.dismiss(); // ??? AlUApplication.getInstance().setUserName(username); Toast.makeText(getApplicationContext(), "?", 0).show(); finish(); } }); } catch (final EaseMobException e) { runOnUiThread(new Runnable() { public void run() { if (!RegisterActivity.this.isFinishing()) pd.dismiss(); int errorCode = e.getErrorCode(); if (errorCode == EMError.NONETWORK_ERROR) { Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT).show(); } else if (errorCode == EMError.USER_ALREADY_EXISTS) { Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT).show(); } else if (errorCode == EMError.UNAUTHORIZED) { Toast.makeText(getApplicationContext(), "???", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), ": " + e.getMessage(), Toast.LENGTH_SHORT).show(); } } }); } } }).start(); } // }
From source file:es.udc.robotcontrol.testapp.comunication.RobotCommController.java
public void iniciar(Context ctx, Intent intent) { Log.i(Constantes.TAG_SERVICIO, "Iniciando controlador de robot"); try {/*from www . ja v a 2 s. c o m*/ continuar = true; Log.i(Constantes.TAG_SERVICIO, "Creando conector Placa"); conector = new ConectorPlaca(); Log.i(Constantes.TAG_SERVICIO, "Conector placa creado. Llamando a conectar"); conector.conectar(ctx, intent); Log.i(Constantes.TAG_SERVICIO, "La llamada a conectar ha tenido exito"); Toast.makeText(ctx, R.string.robot_service_started, Toast.LENGTH_SHORT).show(); Log.i(Constantes.TAG_SERVICIO, "Creando hilo escritor"); escritor = new HiloEscritor(this); Log.i(Constantes.TAG_SERVICIO, "Creando hilo lector"); lector = new HiloLector(this); Log.i(Constantes.TAG_SERVICIO, "Lanzando hilo lector"); lector.start(); Log.i(Constantes.TAG_SERVICIO, "Lanzando hilo escritor"); escritor.start(); Log.i(Constantes.TAG_SERVICIO, "Todos los hilos han sido lanzados. iniciar completado."); } catch (Exception ex) { Log.w(Constantes.TAG_SERVICIO, "Error iniciando conexion [ " + ex.getMessage() + " ] ", ex); Toast.makeText(ctx, R.string.robot_service_error_connection, Toast.LENGTH_SHORT).show(); } }
From source file:io.v.positioning.MainActivity.java
public void onRecordMyLocation(View view) { updateLocation();/* w w w .j av a2s . co m*/ if (mLatitude != null && mLongitude != null) { try { JSONObject data = new JSONObject(); data.put("androidId", Settings.Secure.getString(this.getBaseContext().getContentResolver(), Settings.Secure.ANDROID_ID)); data.put("latitude", mLatitude); data.put("longitude", mLongitude); data.put("deviceTime", System.currentTimeMillis()); new ServletPostAsyncTask("gps", data).execute(this); } catch (JSONException | MalformedURLException e) { Log.e(TAG, "Failed to record the location." + e); } } else { Toast.makeText(this, "Latitude and longitude not set.", Toast.LENGTH_SHORT).show(); } }
From source file:com.manning.androidhacks.hack022.androidlib.LoginActivity.java
protected void onLoginPress() { String user = mEmail.getText().toString(); String passwd = mPassword.getText().toString(); if (mLoginModel.login(user, passwd)) { Toast.makeText(this, "Logged in", Toast.LENGTH_SHORT).show(); } else {/* w ww .j av a 2 s.c o m*/ Toast.makeText(this, "Login failed", Toast.LENGTH_SHORT).show(); } }
From source file:asynctasks.AddTicketDataAsync.java
@Override protected void onPostExecute(JSONObject json) { pDialog.cancel();//from w w w. ja va 2s. c om int success; try { success = json.getInt("success"); if (success == 1) { NewTicket frag = (NewTicket) fm.findFragmentByTag("New Ticket"); frag.dismiss(); } else { Toast.makeText(context, "ERROR IN SUBMISSION", Toast.LENGTH_SHORT).show(); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.longle1.facedetection.TimedAsyncHttpResponseHandler.java
@Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { Log.i("RTT", String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms"); String msg = "RTT: " + String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms"; Toast mToast = Toast.makeText(mContext, msg, Toast.LENGTH_SHORT); mToast.setGravity(Gravity.TOP, 0, 0); mToast.show();// w w w . j a v a 2 s . co m }
From source file:im.afterclass.android.activity.RegisterActivity.java
/** * /*from w w w . java 2s . c o m*/ * @param view */ public void register(View view) { final String username = userNameEditText.getText().toString().trim(); final String pwd = passwordEditText.getText().toString().trim(); String confirm_pwd = confirmPwdEditText.getText().toString().trim(); if (TextUtils.isEmpty(username)) { Toast.makeText(this, "????", Toast.LENGTH_SHORT).show(); userNameEditText.requestFocus(); return; } else if (TextUtils.isEmpty(pwd)) { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); passwordEditText.requestFocus(); return; } else if (TextUtils.isEmpty(confirm_pwd)) { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); confirmPwdEditText.requestFocus(); return; } else if (!pwd.equals(confirm_pwd)) { Toast.makeText(this, "????", Toast.LENGTH_SHORT).show(); return; } if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) { final ProgressDialog pd = new ProgressDialog(this); pd.setMessage("..."); pd.show(); new Thread(new Runnable() { public void run() { try { //sdk EMChatManager.getInstance().createAccountOnServer(username, pwd); runOnUiThread(new Runnable() { public void run() { if (!RegisterActivity.this.isFinishing()) pd.dismiss(); //??? DemoApplication.getInstance().setUserName(username); Toast.makeText(getApplicationContext(), "?", 0).show(); newRegister(); finish(); } }); } catch (final Exception e) { runOnUiThread(new Runnable() { public void run() { if (!RegisterActivity.this.isFinishing()) pd.dismiss(); if (e != null && e.getMessage() != null) { String errorMsg = e.getMessage(); if (errorMsg.indexOf("EMNetworkUnconnectedException") != -1) { Toast.makeText(getApplicationContext(), "?", 0).show(); } else if (errorMsg.indexOf("conflict") != -1) { Toast.makeText(getApplicationContext(), "?", 0).show(); } else { Toast.makeText(getApplicationContext(), ": " + e.getMessage(), 1).show(); } } else { Toast.makeText(getApplicationContext(), ": ", 1).show(); } } }); } } }).start(); } }
From source file:com.ddpclient.spiovesan.ddpclient.LogService.java
@Override public void onDestroy() { super.onDestroy(); //Stop the Background thread isRunning = false;/*from www .ja v a 2 s . c o m*/ //Announcement about stopping Toast.makeText(this, "Stopping the Log Service", Toast.LENGTH_SHORT).show(); }