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:ca.lightseed.winston.WinstonService.java

/**
 * Creates the partial wake-lock which keeps CPU running, and allows this service
 * to continue passing location data even with screen off.
 * NOTE: WakeLocks consume battery very quickly.
 *///  w  w w. j  ava  2s. c  o  m
@Override
public void onCreate() {
    super.onCreate();
    PowerManager pm = (PowerManager) getSystemService(this.POWER_SERVICE);

    wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "DoNotSleep");
    // TODO: Intrusively many toasts are generated. Fine for testing, not fine for release.
    Toast.makeText(this, "Created Winston tracking service", Toast.LENGTH_SHORT).show();
}

From source file:io.cloudmatch.demo.pinchanddrag.PADServerEventListener.java

@Override
public void onConnectionOpen() {
    Log.d(TAG, "onConnectionOpen");
    Toast.makeText(mActivity, mActivity.getString(R.string.connected), Toast.LENGTH_SHORT).show();
}

From source file:com.imalu.alyou.activity.RegisterActivity_first.java

/**
 * ?//from www .  j  ava 2s . c  o m
 * 
 * @param view
 */
public void next(View view) {

    final String phone = phoneNumberEditText.getText().toString().trim();
    isPhone = isMobileNum(phone);
    Log.i("BBBBBBBB", "" + isPhone);
    if (TextUtils.isEmpty(phone)) {
        Toast.makeText(this, "???", Toast.LENGTH_SHORT).show();
        phoneNumberEditText.requestFocus();
        return;
    } else if (isPhone == false) {
        Toast.makeText(this, "???", Toast.LENGTH_SHORT).show();
        phoneNumberEditText.requestFocus();
        return;
    }
    Intent intent = new Intent(RegisterActivity_first.this, RegisterActivity_second.class);
    intent.putExtra("phone", phone);
    startActivity(intent);
    finish();
}

From source file:com.parking.auth.RegisterUserActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.register_user);

    deviceId = ParkingApplication.getDeviceId();

    userNameText = (EditText) findViewById(R.id.nUsername);
    userNameText.setText(ParkingApplication.getAccount().name);
    userNameText.setEnabled(false);/*from  ww  w .java 2  s  .c om*/

    fullNameText = (EditText) findViewById(R.id.nFullName);
    licensePlateNumbersText = (EditText) findViewById(R.id.nLicensePlates);

    clearButton = (Button) findViewById(R.id.nClear);
    clearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            fullNameText.setText("");
            licensePlateNumbersText.setText("");
        }
    });

    submitButton = (Button) findViewById(R.id.nRegister);
    submitButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            String licensePlateNumbersString = licensePlateNumbersText.getText().toString();

            /** Sanity for license plate number */
            if (licensePlateNumbersString.length() < MIN_LICENSE_PLATE_LENGTH) {
                Toast.makeText(RegisterUserActivity.this, "Please enter valid license plate information",
                        Toast.LENGTH_SHORT);
                clearButton.performClick();
                return;
            }

            AppPreferences.getInstance().setLicensePlateString(licensePlateNumbersString);

            List<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("username", ParkingApplication.getAccount().name));
            nameValuePairs.add(new BasicNameValuePair("deviceId", deviceId));
            nameValuePairs.add(new BasicNameValuePair("authToken", ParkingApplication.getAuthToken()));
            nameValuePairs.add(new BasicNameValuePair("isDevice", "true"));
            nameValuePairs.add(new BasicNameValuePair("license", licensePlateNumbersText.getText().toString()));
            new RegisterUserAsyncTask(RegisterUserActivity.this, RegisterUserActivity.this)
                    .execute(nameValuePairs);
        }
    });
}

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

public void onLoop1Click(View v) {
    if (!canWriteInExternalStorage()) {
        Toast.makeText(this, "Can't write file", Toast.LENGTH_SHORT).show();
        return;/*from  ww  w.j  a  v a2 s.c o  m*/
    }

    Log.d("TAG", "LOOP1: " + LOOP1_PATH);
    MediaUtils.saveRaw(this, R.raw.loop1, LOOP1_PATH);

    ContentValues values = new ContentValues(5);
    values.put(Media.ARTIST, "Android");
    values.put(Media.ALBUM, "60AH");
    values.put(Media.TITLE, "hack043");
    values.put(Media.MIME_TYPE, "audio/mp3");
    values.put(Media.DATA, LOOP1_PATH);

    getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
}

From source file:com.dimasdanz.kendalipintu.util.AdminLoginDialog.java

@Override
protected void onDialogClosed(boolean positiveResult) {
    if (positiveResult) {
        if (SharedPreferencesManager.getIsAdminPrefs(getContext())) {
            SharedPreferencesManager.setAsAdmin(getContext(), false, null);
            Toast.makeText(getContext(), R.string.toast_admin_logout_success, Toast.LENGTH_SHORT).show();
        } else {//from   ww  w  . j  a  v  a 2  s. co m
            EditText username = (EditText) mView.findViewById(R.id.input_username);
            EditText password = (EditText) mView.findViewById(R.id.input_password);
            new sendAdminLogin().execute(username.getText().toString(), password.getText().toString());
        }
    }
}

From source file:com.wenwen.chatuidemo.activity.RegisterActivity.java

/**
 * /*  w  ww .j  a va2 s  .  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("...");
        RequestParams params = new RequestParams();
        params.put("username", userNameEditText.getText().toString().trim());
        params.put("password", MD5.md5("ys_" + passwordEditText.getText().toString().trim()).toUpperCase());
        params.put("type", "1");
        HttpClientRequest.post(Urls.REG, params, 3000, new AsyncHttpResponseHandler() {
            @Override
            public void onStart() {
                // TODO Auto-generated method stub
                super.onStart();
                pd.show();
            }

            @Override
            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
                // TODO Auto-generated method stub
                try {
                    String res = new String(arg2);
                    DebugLog.i("res", res);
                    JSONObject result = new JSONObject(res);
                    switch (Integer.valueOf(result.getString("ret"))) {
                    case -1:
                        Toast.makeText(RegisterActivity.this, "?", Toast.LENGTH_SHORT).show();
                        break;
                    case 1:
                        Toast.makeText(RegisterActivity.this, "?", Toast.LENGTH_SHORT).show();
                        DemoApplication.getInstance().setUserName(userNameEditText.getText().toString().trim());
                        DemoApplication.getInstance().setUserUid(result.getString("uid"));
                        Intent intent = new Intent(RegisterActivity.this, PersonalData.class);
                        startActivity(intent);
                        finish();
                        break;
                    case 0:
                    case -2:
                    case -9:
                        Toast.makeText(RegisterActivity.this, "", Toast.LENGTH_SHORT).show();
                        break;
                    default:
                        break;
                    }
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

            @Override
            public void onFinish() {
                // TODO Auto-generated method stub
                super.onFinish();
                pd.dismiss();
            }

            @Override
            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {

            }
        });

    }
}

From source file:com.ppdl.microphone.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    sp.edit().remove(Constant.EXTRA_INFILE).commit(); // infile?PCM?????

    Button recordButton = (Button) findViewById(R.id.buttonRecord);
    recordButton.setOnTouchListener(new View.OnTouchListener() {

        @Override//from  w  w w.  ja v a 2 s  . c  o  m
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                startRecording();
                Toast.makeText(MainActivity.this, "Start Recording", Toast.LENGTH_SHORT).show();
                break;

            case MotionEvent.ACTION_UP:
                stopRecording();
                v.performClick();
                Toast.makeText(MainActivity.this, "Stop Recording", Toast.LENGTH_SHORT).show();
                break;

            default:
                break;
            }
            return false;
        }
    });

    Button playButton = (Button) findViewById(R.id.buttonPlay);
    playButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startPlaying();
        }
    });

    Button stopButton = (Button) findViewById(R.id.buttonStop);
    stopButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            stopPlaying();
        }
    });

    Button recognizeButton = (Button) findViewById(R.id.buttonRecognize);
    recognizeButton.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                Toast.makeText(MainActivity.this, "Start Recognizing", Toast.LENGTH_SHORT).show();
                speechRecognizer.cancel();
                Intent intent = new Intent();
                bindParams(intent);
                intent.putExtra("vad", "touch");
                speechRecognizer.startListening(intent);
                break;

            case MotionEvent.ACTION_UP:
                v.performClick();
                Toast.makeText(MainActivity.this, "Stop Recognizing", Toast.LENGTH_SHORT).show();
                speechRecognizer.stopListening();
                break;

            default:
                break;
            }
            return false;
        }
    });

    speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this,
            new ComponentName(this, VoiceRecognitionService.class));
    speechRecognizer.setRecognitionListener(mRecognitionListner);
}

From source file:com.facebook.android.FieldsConnectionsDialog.java

public FieldsConnectionsDialog(GraphExplorer explorerActivity, JSONObject metadata) {
    super(explorerActivity);
    this.explorerActivity = explorerActivity;

    /*//  w w  w .  j a  v a2s. co m
     * Sort the fields and connections
     */
    try {
        sortFields(metadata.getJSONArray("fields"));
        sortConnections(metadata.getJSONObject("connections").names());
    } catch (JSONException e) {
        Toast.makeText(explorerActivity.getBaseContext(), "Fields/Connections could not be fetched.",
                Toast.LENGTH_SHORT).show();
    }

    setTitle(explorerActivity.getString(R.string.fields_and_connections));
    fieldsVector = new Vector<String>();
}