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:edu.cwru.apo.News.java
public void onRestRequestComplete(Methods method, JSONObject result) { if (method == Methods.checkCredentials) { if (result != null) { String requestStatus; try { requestStatus = result.getString("requestStatus"); if (requestStatus.compareTo("valid") == 0) { // put message here Toast msg = Toast.makeText(getApplicationContext(), "Success!", Toast.LENGTH_LONG); msg.show();/* w ww. j a v a 2 s . com*/ } else { Toast msg = Toast.makeText(getApplicationContext(), "Failure", Toast.LENGTH_LONG); msg.show(); } } catch (JSONException e) { // TODO Auto-generated catch block // put invalid JSON message here Toast msg = Toast.makeText(getApplicationContext(), "JSON Error: Invalid element", Toast.LENGTH_LONG); msg.show(); e.printStackTrace(); } } else { Toast msg = Toast.makeText(getApplicationContext(), "Error: result is null", Toast.LENGTH_LONG); msg.show(); } } else { Toast msg = Toast.makeText(getApplicationContext(), "Invalid method called", Toast.LENGTH_LONG); msg.show(); } }
From source file:com.applechip.android.showcase.rest.HttpGetSetRequestTimeoutActivity.java
private void showResponse(String response) { if (response != null) { Toast.makeText(this, response, Toast.LENGTH_LONG).show(); } }
From source file:com.mobshep.sessionmanagement.MainActivity.java
public void getKeyClicked(View v) { SharedPreferences prefs = this.getSharedPreferences("SessionToken", MODE_PRIVATE); String session = prefs.getString("SessionToken", null); if (session == null) { Toast noSession = Toast.makeText(MainActivity.this, "You do not have an active session!", Toast.LENGTH_LONG); noSession.show();/* w w w .ja va2 s .c o m*/ } else { // temp solution until SSO is implemented Toast gettingKey = Toast.makeText(MainActivity.this, "Getting the key...", Toast.LENGTH_LONG); gettingKey.show(); showKey.setText("BlueBanjosNewNachos"); } }
From source file:com.example.AllSOSservice.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), Activity.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);/* w w w . j a va2s .c o m*/ String message = intent.getStringExtra("message"); String email = intent.getStringExtra("email"); String latitude = intent.getStringExtra("latitude"); String longitude = intent.getStringExtra("longitude"); Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG); toast.show(); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher).setContentTitle("Novo Pedido de Ajuda!") .setContentText("Alguem precisa de um " + message); Intent resultIntent = null; try { if (isLoggedIn()) { resultIntent = new Intent(context, LoggedInActivity.class); } else { resultIntent = new Intent(context, LoginActivity.class); } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } catch (TimeoutException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } // Because clicking the notification opens a new ("special") activity, there's // no need to create an artificial back stack. PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); int mNotificationId = 001; // Gets an instance of the NotificationManager service NotificationManager mNotifyMgr = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // Builds the notification and issues it. mNotifyMgr.notify(mNotificationId, mBuilder.build()); }
From source file:com.pansapiens.occyd.MapResults.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // receive search results from calling Activity, // as a raw json string Bundle incoming_data = getIntent().getExtras(); String json_txt = null;//from w ww .j a v a 2 s .c o m ArrayList<Post> post_results = new ArrayList(); if (incoming_data != null) { json_txt = incoming_data.getString("json"); try { post_results = JSONdecoder.json2postArray(json_txt); } catch (JSONException e) { Toast.makeText(MapResults.this, "FAIL: Malformed response from server.", Toast.LENGTH_LONG).show(); } } setContentView(R.layout.mapview); map = (MapView) findViewById(R.id.map); // zoom controls are placed in their own 'sub-layout' called // "@+id/zoom" in the mapview.xml layout. // this ensures they are correctly positioned, don't scroll offscreen // and don't prevent touch scrolling of the map when visible LinearLayout zoomView = (LinearLayout) findViewById(R.id.zoom); zoomView.addView(map.getZoomControls()); // (straight out of the MapViewCompassDemo.java API Demos) // put a dot on our current location once we have a fix mMyLocationOverlay = new MyLocationOverlay(this, map); mMyLocationOverlay.runOnFirstFix(new Runnable() { public void run() { map.getController().animateTo(mMyLocationOverlay.getMyLocation()); } }); map.getOverlays().add(mMyLocationOverlay); map.getController().setZoom(17); locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); LocationUpdater locupdater = new LocationUpdater(locationManager, this); locupdater.startUpdating(); // add markers for search results // marker from: http://commons.wikimedia.org/wiki/File:Map_symbol_location_02.png Drawable marker = getResources().getDrawable(R.drawable.marker); marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight()); map.getOverlays().add(new MapResultsOverlay(marker, post_results)); //map.getOverlays().add(new MapResultsOverlay(marker)); // dummy testing constructor .... }
From source file:com.otaupdater.utils.UserUtils.java
public static void showLoginDialog(final Context ctx, String defUsername, final DialogCallback dlgCallback, final LoginCallback loginCallback) { @SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.login_dialog, null); if (view == null) return;//w w w . ja v a 2 s . com final EditText inputUsername = (EditText) view.findViewById(R.id.auth_username); final EditText inputPassword = (EditText) view.findViewById(R.id.auth_password); if (defUsername != null) inputUsername.setText(defUsername); AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle(R.string.alert_login_title); builder.setView(view); builder.setPositiveButton(R.string.login, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { /* set below */ } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (loginCallback != null) loginCallback.onCancel(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { if (dlgCallback != null) dlgCallback.onDialogShown(dlg); Button button = dlg.getButton(DialogInterface.BUTTON_POSITIVE); if (button == null) return; button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String username = inputUsername.getText().toString(); final String password = inputPassword.getText().toString(); if (username.length() == 0 || password.length() == 0) { Toast.makeText(ctx, R.string.toast_blank_userpass_error, Toast.LENGTH_LONG).show(); return; } dlg.dismiss(); APIUtils.userLogin(ctx, username, password, new APIUtils.ProgressDialogAPICallback(ctx, ctx.getString(R.string.alert_logging_in), dlgCallback) { @Override public void onSuccess(String message, JSONObject respObj) { try { String realUsername = respObj.getString("username"); String hmacKey = respObj.getString("key"); Config.getInstance(ctx).storeLogin(realUsername, hmacKey); if (loginCallback != null) loginCallback.onLoggedIn(realUsername); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onError(String message, JSONObject respObj) { //TODO show some error } }); } }); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (dlgCallback != null) dlgCallback.onDialogClosed(dlg); } }); dlg.show(); }
From source file:com.liferay.mobile.sample.activity.MainActivity.java
@Override public void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.main);/* w w w . ja v a2s. co m*/ String server = getString(R.string.oauth_server); String consumerKey = getString(R.string.oauth_consumer_key); String consumerSecret = getString(R.string.oauth_consumer_secret); if (Validator.isNull(server) || Validator.isNull(consumerKey) || Validator.isNull(consumerSecret)) { Toast.makeText(this, "oauth.xml is not properly configured.", Toast.LENGTH_LONG).show(); return; } final OAuthConfig config = new OAuthConfig(server, consumerKey, consumerSecret); Button login = (Button) findViewById(R.id.login); _webView = (OAuthWebView) findViewById(R.id.webView); login.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { _webView.loadUrl("about:blank"); _webView.setVisibility(View.VISIBLE); _webView.start(config, MainActivity.this); } }); }
From source file:com.eyekabob.VenueList.java
protected void loadVenues(JSONObject response) { try {// ww w . j av a 2s . c o m JSONObject venues = response.getJSONObject("results"); JSONObject matches = venues.getJSONObject("venuematches"); Object jsonVenueObj = matches.get("venue"); JSONArray jsonVenue; if (jsonVenueObj instanceof JSONObject) { // Only one venue result was returned. So wrap it in an array. jsonVenue = new JSONArray(); jsonVenue.put(jsonVenueObj); } else { jsonVenue = (JSONArray) jsonVenueObj; } if (jsonVenue.length() == 0) { Toast.makeText(getApplicationContext(), R.string.no_results, Toast.LENGTH_LONG).show(); return; } for (int i = 0; i < jsonVenue.length(); i++) { JSONObject venue = jsonVenue.getJSONObject(i); JSONObject location = venue.getJSONObject("location"); Venue venueRow = new Venue(); venueRow.setId(venue.optString("id")); venueRow.setName(venue.optString("name")); venueRow.setUrl(venue.optString("url")); venueRow.setCity(location.optString("city")); venueRow.setCountry(location.optString("country")); venueRow.setStreet(location.optString("street")); JSONObject geoPoint = venue.optJSONObject("geo:point"); if (geoPoint != null) { venueRow.setLat(geoPoint.optString("geo:lat")); venueRow.setLon(geoPoint.optString("geo:long")); } adapter.add(venueRow); } } catch (JSONException e) { Log.e(getClass().getName(), "Unable to load venue list", e); Toast.makeText(this, R.string.venue_list_error, Toast.LENGTH_LONG).show(); } }
From source file:com.eyekabob.ArtistList.java
protected void loadLastFMArtists(JSONObject response) { try {//from w ww . j ava2s . c o m if (response == null || !response.has("results")) { Toast.makeText(this, R.string.no_results, Toast.LENGTH_LONG).show(); return; } JSONObject results = response.getJSONObject("results"); Object artistMatchesObj = results.get("artistmatches"); if (artistMatchesObj instanceof String) { Toast.makeText(this, R.string.no_results, Toast.LENGTH_LONG).show(); return; } JSONArray artists = ((JSONObject) artistMatchesObj).getJSONArray("artist"); for (int i = 0; i < artists.length(); i++) { JSONObject artistNode = artists.getJSONObject(i); String name = artistNode.getString("name"); String mbid = artistNode.getString("mbid"); String url = artistNode.getString("url"); JSONObject jsonImage = EyekabobHelper.LastFM.getJSONImage("large", artistNode.getJSONArray("image")); Artist artist = new Artist(); artist.setName(name); artist.setMbid(mbid); artist.setUrl(url); artist.addImageURL("large", jsonImage.getString("#text")); adapter.add(artist); } } catch (JSONException e) { Log.e(getClass().getName(), "JSON was not in the expected format", e); } }
From source file:br.edu.fpu.exemploauth.MainActivity.java
private void displayResponse(Message response) { Toast.makeText(this, response.getText(), Toast.LENGTH_LONG).show(); }