Example usage for android.widget Toast show

List of usage examples for android.widget Toast show

Introduction

In this page you can find the example usage for android.widget Toast show.

Prototype

public void show() 

Source Link

Document

Show the view for the specified duration.

Usage

From source file:eltharis.wsn.showAllActivity.java

/**
 * Called when the activity is first created.
 *//*from   ww w  . j a  v a  2  s  . co m*/
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    try {
        String response = executeGET();
        showAll(response);
    } catch (Exception e) {
        Toast toast = Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG); //do debuggowania
        toast.show();
    }
    adapter = new ArrayAdapter<User>(this, android.R.layout.simple_list_item_1, users);
    setListAdapter(adapter);
    ListView lv = getListView();
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { //nasuchiwanie, czy jaki z uytkownikw by nacinity

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = ((TextView) view).getText().toString();
            Toast.makeText(getBaseContext(), username, Toast.LENGTH_SHORT).show();
            User selected = null;
            for (User u : users) {
                if (u.getUsername().equals(username)) {
                    selected = u;
                    break;
                }
            }
            if (selected != null) {
                Intent intent = new Intent(getBaseContext(), showIDActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.putExtra("id", selected.getId()); //dodajemy jako Extra do intentu. S to tak jakby parametry
                getBaseContext().startActivity(intent); //zaczynamy intent
            }
        }
    });
}

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();
}

From source file:de.bolz.android.taglocate.ui.TagEditActivity.java

/**
 * Shows a Toast on top of the view.//from   w  w w .j a  v a2s  .  c  o  m
 * @param msg the message to display.
 * @param length the Toast duration
 */
protected void showToast(String msg, int length) {
    Toast t = Toast.makeText(this, msg, length);
    t.setGravity(Gravity.TOP, 0, 0);
    t.show();
}

From source file:com.mobshep.shepherdlogin.LoggedIn.java

public void submitClicked(View v) {

    String apiKey = "thisIsTheAPIKey";

    ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
    postParameters.add(new BasicNameValuePair("mobileKey", apiKey));

    try {//from  w w  w .ja  va2 s  .com

        SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        String address = SP.getString("server_preference", "NA");

        String res = CustomHttpClient.executeHttpPost(address + "/vulMobileAPI", postParameters);

        JSONObject jObject = new JSONObject(res.toString());

        String response = jObject.getString("LEVELKEY");

        response = response.replaceAll("\\s+", "");

        Toast responseError = Toast.makeText(LoggedIn.this, response.toString(), Toast.LENGTH_SHORT);
        responseError.show();

        if (res != null) {
            storedPref = getSharedPreferences("Sessions", MODE_PRIVATE);
            toEdit = storedPref.edit();
            toEdit.putString("LEVELKEY", response);
            toEdit.commit();

        } else {
            Toast.makeText(getBaseContext(), "Invalid API Key!", Toast.LENGTH_SHORT).show();
        }
    } catch (Exception e) {

        Toast responseError = Toast.makeText(LoggedIn.this, e.toString(), Toast.LENGTH_LONG);
        responseError.show();
    }

}

From source file:co.edu.uniajc.vtf.security.controller.CreateAccountController.java

private void createAccount(int pResult) {
    ResourcesManager loResource = new ResourcesManager((Activity) this.coView);
    String lsMessage = "";

    if (pResult == 0) {
        lsMessage = loResource.getStringResource(R.string.create_account_successfully_message);
        SessionManager loSession = new SessionManager((Activity) this.coView);

        try {//from w  ww  . jav  a2s. c  o m
            UserEntity loUser = new UserEntity();
            String lsPasswordEncrypt = DigestManager.digestSHA1(this.coView.getPassword());
            loUser.setEmail(this.coView.getEmail());
            loUser.setPassword(lsPasswordEncrypt);
            loUser.setNames(this.coView.getNames());
            loUser.setGender(this.coView.getMale() ? 1 : 2);
            loSession.createSession(loUser, SessionManager.SIMPLE_SESSION);
        } catch (Exception e) {
            lsMessage = loResource.getStringResource(R.string.general_message_error);
        }

    } else if (pResult == 1) {
        lsMessage = loResource.getStringResource(R.string.create_account_error_message);
    } else {
        lsMessage = loResource.getStringResource(R.string.general_message_error);
    }

    Toast toast = Toast.makeText((Activity) this.coView, lsMessage, Toast.LENGTH_LONG);
    toast.show();

    if (pResult == 0) {
        this.navigateContent();
    }
}

From source file:eltharis.wsn.showAllActivity.java

private String executeGET() throws Exception {
    HttpClient httpclient = new DefaultHttpClient(); //Korzystamy z Apache, ktry jest w Android
    HttpResponse response = httpclient/*  ww  w .  j a v a 2s .  co m*/
            .execute(new HttpGet("https://agile-depths-5530.herokuapp.com/usershow/")); //kaemy mu wykona GETa
    StatusLine statusline = response.getStatusLine(); //sprawdzamy status
    Toast toast = Toast.makeText(getApplicationContext(),
            "HTTP Response: " + Integer.toString(statusline.getStatusCode()), Toast.LENGTH_LONG);
    toast.show(); //prosty Toast z HttpStatusCode
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    response.getEntity().writeTo(out); //zapisujemy dane HTTP do ByteArrayOutputStream
    String responseString = out.toString();
    out.close(); //zamykamy OutputStream
    return responseString;
}

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);/*from   w  w w  .  ja va 2  s.  co m*/
        noSession.show();
    }

    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.arthackday.killerapp.util.Util.java

public void popup(String msg) {
    CharSequence text = msg;// w  w  w .ja va2 s  . c  om
    int duration = Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(activity, text, duration);
    toast.show();
}

From source file:ua.naiksoftware.chars.Sender.java

@Override
protected void onPostExecute(Boolean result) {
    Log.d(tag, "onPostExecute begin with " + result);
    try {/*  w  ww .j  a v a 2 s  .co  m*/
        if (result) {
            Toast toast = Toast.makeText(EngineActivity.CONTEXT, R.string.send_ok, Toast.LENGTH_LONG);
            toast.show();
        } else {
            Toast toast = Toast.makeText(EngineActivity.CONTEXT, err, Toast.LENGTH_LONG);
            toast.show();
        }
        dialog.dismiss();
        target.finish();
    } catch (Exception e) {
        Log.e("Sender", "onPostExecute exception", e);
    }
}

From source file:com.lingeringsocket.mobflare.Main.java

private void locationError() {
    Toast toast = Toast.makeText(this, R.string.no_location, Toast.LENGTH_LONG);
    toast.show();
}