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:mobisocial.musubi.ui.fragments.ChooseImageDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    return new AlertDialog.Builder(getActivity()).setTitle("Choose an Image...")
            .setItems(new String[] { "From Camera", "From Gallery" }, new DialogInterface.OnClickListener() {
                @SuppressWarnings("deprecation")
                @Override//  w w  w  .j a  v a 2s .co  m
                public void onClick(DialogInterface dialog, int which) {
                    switch (which) {
                    case 0:
                        final Activity activity = getActivity();
                        Toast.makeText(activity, "Loading camera...", Toast.LENGTH_SHORT).show();
                        ((InstrumentedActivity) activity)
                                .doActivityForResult(new PhotoTaker(activity, new PhotoTaker.ResultHandler() {
                                    @Override
                                    public void onResult(Uri imageUri) {
                                        Log.d(getClass().getSimpleName(), "Updating thumbnail...");

                                        try {
                                            UriImage image = new UriImage(activity, imageUri);
                                            byte[] data = image.getResizedImageData(512, 512,
                                                    PictureObj.MAX_IMAGE_SIZE / 2);
                                            // profile
                                            Bitmap sourceBitmap = BitmapFactory.decodeByteArray(data, 0,
                                                    data.length);
                                            int width = sourceBitmap.getWidth();
                                            int height = sourceBitmap.getHeight();
                                            int cropSize = Math.min(width, height);
                                            Bitmap cropped = Bitmap.createBitmap(sourceBitmap, 0, 0, cropSize,
                                                    cropSize);
                                            ByteArrayOutputStream baos = new ByteArrayOutputStream();
                                            cropped.compress(Bitmap.CompressFormat.JPEG, 90, baos);
                                            cropped.recycle();
                                            sourceBitmap.recycle();

                                            Bundle bundle = new Bundle();
                                            bundle.putByteArray(EXTRA_THUMBNAIL, baos.toByteArray());
                                            Intent res = new Intent();
                                            res.putExtras(bundle);
                                            getTargetFragment().onActivityResult(REQUEST_PROFILE_PICTURE,
                                                    Activity.RESULT_OK, res);
                                        } catch (Throwable t) {
                                            Log.e("ViewProfile", "failed to generate thumbnail of profile", t);
                                            Toast.makeText(activity,
                                                    "Profile picture capture failed.  Try again.",
                                                    Toast.LENGTH_SHORT).show();
                                        }
                                    }
                                }, 200, false));
                        break;
                    case 1:
                        Intent gallery = new Intent(Intent.ACTION_GET_CONTENT);
                        gallery.setType("image/*");
                        // god damn fragments.
                        getTargetFragment().startActivityForResult(Intent.createChooser(gallery, null),
                                REQUEST_GALLERY_THUMBNAIL);
                        break;
                    }
                }
            }).create();
}

From source file:com.manning.androidhacks.hack046.ReplyActivity.java

public void onSendClick(View v) {
    String msg = mEditText.getText().toString();

    if (TextUtils.isEmpty(msg)) {
        Toast.makeText(this, "Empty msg!", Toast.LENGTH_SHORT).show();
        return;//  ww  w  . ja v  a 2  s . com
    }

    Intent intent = new Intent(this, MsgService.class);
    intent.setAction(MsgService.MSG_REPLY);
    intent.putExtra(MsgService.MSG_REPLY_KEY, msg);
    startService(intent);

    finish();
}

From source file:com.mobshep.insufficienttls.InsufficientTLS.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    setContentView(R.layout.layout);/* www .  j av  a  2s.c  o  m*/
    referenceXML();

    if (isNetworkAvailable() == false) {
        Toast networkError = Toast.makeText(InsufficientTLS.this, "No Network Connection Detected.",
                Toast.LENGTH_SHORT);
        networkError.show();
    }
}

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

public void bottomRight(View v) {
    Toast toast = Toast.makeText(this, "Bottom Right!", Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.BOTTOM | Gravity.RIGHT, 0, 0);
    toast.show();/*from ww w  . ja  v a  2  s  .  c  om*/
}

From source file:org.flakor.androidtool.net.net.HistoryTask.java

@Override
protected void onPostExecute(Integer i) {
    if (i < 0) {
        if (dialog != null)
            dialog.dismiss();//from  w  w  w  . ja  v a 2  s. c o  m
        Toast.makeText(context, "?", Toast.LENGTH_SHORT).show();
    } else if (i >= 0) {
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_history, null);
        ListView list = (ListView) view.findViewById(R.id.history_list);
        if (i == 0) {
            TextView noHistory = (TextView) view.findViewById(R.id.no_history);
            noHistory.setVisibility(View.VISIBLE);
            list.setVisibility(View.GONE);
        } else {
            RemoteHistoryAdapter adapter = new RemoteHistoryAdapter(context);
            list.setAdapter(adapter);
        }
        TextView title = (TextView) view.findViewById(R.id.dialog_title);
        title.setText("??");
        Button okBtn = (Button) view.findViewById(R.id.ok_btn);
        okBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        dialog.setContentView(view);

        Toast.makeText(context, "??", Toast.LENGTH_SHORT).show();
    } else {
        if (dialog != null)
            dialog.dismiss();
        Toast.makeText(context, "???", Toast.LENGTH_SHORT).show();
    }
}

From source file:br.com.oficinapp.blog.restclient.MainActivity.java

/** Lifecycle: Atividade criada. */
@Override//ww  w  .j a v  a 2  s. c  o  m
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.state_list);

    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
        }

    });

}

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

/**
 * ??/*from w  w  w.  j a va  2  s  . c om*/
 * 
 * @param view
 */
public void next(View view) {

    final String identifying_code = identifying_codeEditText.getText().toString().trim();

    if (TextUtils.isEmpty(identifying_code)) {
        Toast.makeText(this, "????", Toast.LENGTH_SHORT).show();
        identifying_codeEditText.requestFocus();
        return;
    } else if (identifying_code.length() != 6) {
        Toast.makeText(this, "?????", Toast.LENGTH_SHORT).show();
        identifying_codeEditText.requestFocus();
        return;
    }
    Intent intent = new Intent(RegisterActivity_second.this, RegisterActivity.class);
    intent.putExtra("phone", phone);
    startActivity(intent);
    finish();
}

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

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

From source file:com.general.vvvv.cmr.MySplash.java

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

    dbLogin = new DbLogin(MySplash.this, DbLogin.DB_NAME, null, DbLogin.DB_VERSION);
    db_read = dbLogin.getReadableDatabase();
    db_write = dbLogin.getWritableDatabase();

    String identifier = null;/*from  www .  ja  v a2  s  .c  o m*/
    TelephonyManager tm = (TelephonyManager) this.getSystemService(this.TELEPHONY_SERVICE);
    if (tm != null) {
        identifier = tm.getDeviceId();
    }
    if (identifier == null || identifier.length() == 0) {
        identifier = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
    }
    Toast.makeText(MySplash.this, "Your IMEI no:" + identifier, Toast.LENGTH_LONG).show();

    System.out.println("IMEI no:" + identifier);
    Log.d("IMEI or Android id:", identifier);

    Cursor cursor = dbLogin.getData(db_read);
    if (cursor.getCount() > 0) {
        Intent intent = new Intent(MySplash.this, MyLogin.class);
        startActivity(intent);
    } else {
        Toast.makeText(MySplash.this, "Login database is empty", Toast.LENGTH_SHORT).show();
        if (identifier != null) {
            new AsynchLogin().execute(identifier);
        } else {
            Toast.makeText(MySplash.this, "Unable to find your IMEI no.", Toast.LENGTH_LONG).show();
        }

    }
}

From source file:org.peterbaldwin.vlcremote.net.ServerConnectionTest.java

@Override
protected void onPostExecute(Integer result) {
    switch (result) {
    case HttpURLConnection.HTTP_UNAUTHORIZED:
        Toast.makeText(context, R.string.server_unauthorized, Toast.LENGTH_SHORT).show();
        break;/*from  ww w  . ja va  2 s  .co m*/
    case HttpURLConnection.HTTP_FORBIDDEN:
        Toast.makeText(context, R.string.server_forbidden, Toast.LENGTH_SHORT).show();
        break;
    case HttpURLConnection.HTTP_OK:
        Toast.makeText(context, R.string.server_ok, Toast.LENGTH_SHORT).show();
        break;
    default:
        Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show();
    }
}