Example usage for android.widget Toast LENGTH_SHORT

List of usage examples for android.widget Toast LENGTH_SHORT

Introduction

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

Prototype

int LENGTH_SHORT

To view the source code for android.widget Toast LENGTH_SHORT.

Click Source Link

Document

Show the view or text notification for a short period of time.

Usage

From source file:asynctasks.UpdateTicketDataAsync.java

@Override
protected void onPostExecute(JSONObject json) {
    pDialog.cancel();// w w w.  j av a2  s .c  o  m
    int success;
    try {
        success = json.getInt("success");
        if (success == 1) {

            SavePicker frag = (SavePicker) fm.findFragmentByTag("Save");
            frag.iCcallback.updateTicket(true);
            frag.dialog.dismiss();

            Toast.makeText(context, "Updated Woot", Toast.LENGTH_SHORT).show();

        } 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.makotosan.vimeodroid.Authentication.java

public static boolean saveAuthentication(Context context, String verifier) {
    final ConsumerInfo info = new ConsumerInfo();

    try {//from  ww  w .j  ava 2  s .  co m
        provider.retrieveAccessToken(consumer, verifier);

        info.setConsumerToken(consumer.getToken());
        info.setConsumerTokenSecret(consumer.getTokenSecret());

        final SharedPreferences myPrefs = context.getSharedPreferences(Authentication.MY_PREFS,
                Context.MODE_PRIVATE);
        final SharedPreferences.Editor editor = myPrefs.edit();

        editor.putString(Authentication.CONSUMER_TOKEN_PREF, info.getConsumerToken());
        editor.putString(Authentication.CONSUMER_TOKEN_SECRET_PREF, info.getConsumerTokenSecret());
        editor.commit();
    } catch (Exception e) {
        // Log.e(TAG, "Unable to save authentication", e);
        Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
        return false;
    }

    return true;
}

From source file:com.yutong.axxc.parents.view.common.ActivityUtils.java

/**
 * ?/* w w  w. j av a  2s.  c o  m*/
 * @param context
 * @param msg
 */
public static void toast(Context context, Object msg) {
    Toast.makeText(context, StringUtil.parseObj2Str(msg), Toast.LENGTH_SHORT).show();
}

From source file:com.andclient.SetupConnectionActivity.java

private void saveSettingsOnClick(View v) {
    int keyboardPort = 0, mousePort = 0;

    EditText et = (EditText) findViewById(R.id.editTextServerIP);
    String ip = et.getText().toString();
    boolean correctIp = InetAddressUtils.isIPv4Address(ip);
    if (!correctIp) {
        Toast.makeText(SetupConnectionActivity.this, "Server IP is not a correct IPv4 address",
                Toast.LENGTH_SHORT).show();
    }// w w  w. j a  va  2 s  . c  o  m

    et = (EditText) findViewById(R.id.editTextMousePort);
    String txt = et.getText().toString();
    if (txt.length() != 0) {
        try {
            mousePort = Integer.parseInt(txt);
        } catch (NumberFormatException e) {
            Toast.makeText(SetupConnectionActivity.this, "Mouse port is not a number", Toast.LENGTH_SHORT)
                    .show();
        }
        if (mousePort < 0) {
            Toast.makeText(SetupConnectionActivity.this, "Mouse port must be greater than 0",
                    Toast.LENGTH_SHORT).show();
        }
    }

    et = (EditText) findViewById(R.id.editTextKeyboardPort);
    txt = et.getText().toString();
    if (txt.length() != 0) {
        try {
            keyboardPort = Integer.parseInt(txt);
        } catch (NumberFormatException e) {
            Toast.makeText(SetupConnectionActivity.this, "Keyboard port must be an integer", Toast.LENGTH_SHORT)
                    .show();
        }
        if (keyboardPort < 0) {
            Toast.makeText(SetupConnectionActivity.this, "Keyboard port must be greater than 0",
                    Toast.LENGTH_SHORT).show();
        }
    }

    if (correctIp && mousePort > 0 && keyboardPort > 0) {
        SharedPreferences.Editor editor = mSettings.edit();
        editor.putString(StartActivity.PREF_SERVER_IP, ip).putInt(StartActivity.PREF_MOUSE_PORT, mousePort)
                .putInt(StartActivity.PREF_KEYBOARD_PORT, keyboardPort);

        editor.commit();
        TextView tv = (TextView) findViewById(R.id.textViewSaveData);
        tv.setTextColor(Color.GREEN);
        tv.setText("Settings saved.");
        tv.setVisibility(View.VISIBLE);
    } else {
        TextView tv = (TextView) findViewById(R.id.textViewSaveData);
        tv.setText("Incorrect input data.");
        tv.setTextColor(Color.RED);
        tv.setVisibility(View.VISIBLE);
    }
}

From source file:hongik.android.project.best.ReviewActivity.java

public void reviewClick(View view) {
    if (view.getId() == R.id.review_submit) {
        String note = ((EditTextPlus) findViewById(R.id.review_text)).getText().toString();
        float grade = ((RatingBar) findViewById(R.id.review_grade)).getRating();

        String query = "func=submitreview" + "&license=" + license + "&cid=" + cid + "&note=" + note + "&grade="
                + grade;/*from ww w  .  j ava2s.  com*/
        DBConnector conn = new DBConnector(query);
        conn.start();

        try {
            conn.join();
            JSONObject jsonResult = conn.getResult();
            boolean result = jsonResult.getBoolean("result");

            if (!result) {
                Toast.makeText(this, "Submit Error", Toast.LENGTH_SHORT).show();
                setResult(0, new Intent());
                finish();
                return;
            }
            Toast.makeText(this, "Thank you for your opinion", Toast.LENGTH_SHORT).show();
            setResult(1, new Intent());
            finish();
        } catch (Exception e) {
        }
    }
}

From source file:com.manning.androidhacks.hack027.MainActivity.java

@Override
public void removeItem(Integer value) {
    mNumbers.remove(value);/*from w  w w  .j av a2s  . c  o m*/
    Toast.makeText(this, "Removed object: " + value, Toast.LENGTH_SHORT).show();
    mAdapter.notifyDataSetChanged();
}

From source file:com.example.loise.saladmotor.JSONUseActivity.java

/** Called when the activity is first created. */

@Override// www.java2  s . c o m

public void onCreate(Bundle savedInstanceState) {

    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()

            .detectDiskReads().detectDiskWrites().detectNetwork() // StrictMode is most commonly used to catch accidental disk or network access on the application's main thread

            .penaltyLog().build());

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_database_conn);

    //Toast.makeText(getApplicationContext(), license.buildbrand.co.ke.DecoderActivity.myTextView.getText().toString(), Toast.LENGTH_LONG).show();

    tv = (TextView) findViewById(R.id.showresult);
    tvtop = (TextView) findViewById(R.id.textView3);
    etphone = (EditText) findViewById(R.id.editText2);
    etname = (EditText) findViewById(R.id.editText);
    etlocation = (EditText) findViewById(R.id.editText3);
    etamount = (EditText) findViewById(R.id.editText4);
    submit = (Button) findViewById(R.id.button3);

    phone = etphone.getText().toString();
    name = etname.getText().toString();
    location = etlocation.getText().toString();
    amount = etamount.getText().toString();

    submit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if (etname.getText().toString().equals("") && etphone.getText().toString().equals("")
                    && etlocation.getText().toString().equals("") && etamount.getText().toString().equals("")) {
                Toast.makeText(getApplicationContext(), "input filed", Toast.LENGTH_SHORT).show();
            } else {
                ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();

                // define the parameter

                postParameters.add(new BasicNameValuePair("name", etname.getText().toString()));
                postParameters.add(new BasicNameValuePair("phone", etphone.getText().toString()));
                postParameters.add(new BasicNameValuePair("location", etlocation.getText().toString()));
                postParameters.add(new BasicNameValuePair("amount", etamount.getText().toString()));
                String response = null;

                // call executeHttpPost method passing necessary parameters

                try {
                    response = CustomHttpClient.executeHttpPost(

                            "http://10.0.2.2/saladmotor/insert.php", // your ip address if using localhost server
                            postParameters);
                    // store the result returned by PHP script that runs MySQL query

                    String result = response.toString();

                    //parse json data

                    try {

                        returnString = "";
                        JSONArray jArray = null;

                        jArray = new JSONArray(result);

                        //JSONObject json_data = jArray.getJSONObject(i);
                        for (int i = 0; i < jArray.length(); i++) {

                            JSONObject json_data = jArray.getJSONObject(i);

                            Log.i("log_tag",
                                    ",name: " + json_data.getString("name") + ",phone: "
                                            + json_data.getString("phone") + ",location: "
                                            + json_data.getString("location") + ",amount: "
                                            + json_data.getString("amount")

                            );

                            //Get an output to the screen
                            //return new JSONObject(json_data.substring(json_data.indexOf("{"), json_data.lastIndexOf("}") + 1));
                            returnString += "\n name: " + json_data.getString("name") + "\n\n phone:  "
                                    + json_data.getString("phone") + "\n\nlocation: "
                                    + json_data.getString("location") + "\n\namount: "
                                    + json_data.getString("location");

                        }

                    } catch (JSONException e) {

                        Log.e("log_tag", "Error parsing data " + e.toString());

                    }

                    try {

                        tv.setText(returnString);
                        if (tv.getText().toString() == "") {

                            tv.setText("NOT FOUND ON THE DATABASE");
                        }

                    } catch (Exception e) {

                        Log.e("log_tag", "Error in Display!" + e.toString());
                        ;

                    }
                    //                        while ((line = reader.readLine()) != null){
                    //                            sb.append(line);
                    //                            json = sb.toString().substring(0, sb.toString().length()-1);
                    //                        }

                } catch (Exception e) {

                    Log.e("log_tag", "Error in http connection!!" + e.toString());

                }
                Toast.makeText(getApplicationContext(), "ordered", Toast.LENGTH_SHORT).show();

            }

        }

    });

    // define the action when user clicks on submit button

}

From source file:net.w3blog.uniwifi3.activity.ContactActivity.java

public void sendMessage(View v) {
    final String email = txtEmail.getText().toString();
    final String title = txtTitle.getText().toString();
    final String message = txtMessage.getText().toString();
    final String id = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);

    new AsyncTask<String, Void, Integer>() {
        @Override//ww w.  jav  a 2  s  . c  o  m
        protected void onPostExecute(Integer result) {
            if (result == HttpStatus.SC_OK) {
                Toast.makeText(ContactActivity.this, R.string.send_sucess, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(ContactActivity.this, R.string.send_fail, Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        protected Integer doInBackground(String... params) {
            final AndroidHttpClient httpClient = AndroidHttpClient.newInstance("Android");
            final HttpPost postRequest = new HttpPost(
                    "http://droidpatterns.com/uniwifi/api.php?m=contact&f=post");

            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4);
            nameValuePairs.add(new BasicNameValuePair("email", params[0]));
            nameValuePairs.add(new BasicNameValuePair("title", params[1]));
            nameValuePairs.add(new BasicNameValuePair("message", params[2]));
            nameValuePairs.add(new BasicNameValuePair("id", params[3]));

            try {
                postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                HttpResponse response = httpClient.execute(postRequest);
                final int statusCode = response.getStatusLine().getStatusCode();
                return statusCode;
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

    }.execute(email, title, message, id);

}