0

I have this button, when it's pressed the image will be saved into the external storage. I want to show a Toast with the text "Your photo has been saved".

Here's my code (but it doesn't show the toast whenever I click save):

save.setOnClickListener(new View.OnClickListener() {
    @SuppressLint("ShowToast")
    @SuppressWarnings("deprecation")

    public void onClick(View v) {
        Log.v(TAG, "Save Tab Clicked");

        viewBitmap = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888);
        canvas = new Canvas(viewBitmap);

        tapimageview.draw(canvas);
        canvas.drawBitmap(bp, 0, 0, paint);
        canvas.drawBitmap(drawingBitmap, matrix, paint);
        canvas.drawBitmap(bmpstickers, matrix, paint);

        //tapimageview.setImageBitmap(mBitmapDrawable.getBitmap());  
        try {
            mBitmapDrawable = new BitmapDrawable(viewBitmap);

            mCurrent = "PXD_" + new SimpleDateFormat("yyyyMMdd_HHmmss",
                Locale.getDefault()).format(new Date()) + ".jpg";

            bp1 = mBitmapDrawable.getBitmap();
            tapimageview.setImageBitmap(bp1);
            mNewSaving = ((BitmapDrawable) mBitmapDrawable).getBitmap();

            String FtoSave = mTempDir + mCurrent;
            File mFile = new File(FtoSave);
            mFileOutputStream = new FileOutputStream(mFile);
            mNewSaving.compress(CompressFormat.JPEG, 100, mFileOutputStream);

            mFileOutputStream.flush();
            mFileOutputStream.close();

        } catch (FileNotFoundException e) {
            Log.v(TAG, "FileNotFoundExceptionError " + e.toString());
        } catch (IOException e) {
            Log.v(TAG, "IOExceptionError " + e.toString());
        }

        Toast.makeText(getApplicationContext(), "Your photo has been saved", Toast.LENGTH_LONG);
    }
});
Capricious frog
  • 104
  • 1
  • 14
user3317993
  • 111
  • 6
  • possible duplicate of [How to display Toast in Android?](http://stackoverflow.com/questions/3500197/how-to-display-toast-in-android) – CJBS Aug 04 '15 at 18:46

4 Answers4

4

You forget .show() in Toast like below:

   Toast.makeText(getApplicationContext(), "Your photo has been saved", Toast.LENGTH_LONG).show();

You can display the toast notification with show().

M D
  • 47,665
  • 9
  • 93
  • 114
0

.show() in Toast

 Toast.makeText(getApplicationContext(), "Your photo has been saved", Toast.LENGTH_LONG).show();
Kanaiya Katarmal
  • 5,974
  • 4
  • 30
  • 56
0

Its strange that the Toast did not show an error. :) You need to add show() at the end.

Toast.makeText(getApplicationContext(), "Your photo has been saved", Toast.LENGTH_LONG).show();
Siddharth_Vyas
  • 9,972
  • 10
  • 39
  • 69
0

just replace this line

 Toast.makeText(getApplicationContext(), "Your photo has been saved", Toast.LENGTH_LONG);

By this line

 Toast.makeText(getApplicationContext(), "Your photo has been saved", Toast.LENGTH_LONG).show();
userAndroid
  • 586
  • 2
  • 9
  • 26