1

sorry for my english :). I need to blur my dialog activity background and I tried this method

Blur BackGround Behind AlertDialog

And I send my bitmap with this code :

Bitmap back1 = takeScreenShot(MainActivity.this);
Bitmap back2 = fastblur(back1, 10);
Intent intent = new Intent(getApplicationContext(), FilterActivity.class);
intent.putExtra("back", back2);
startActivity(intent);

And recieve bitmap in my activity :

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = new Intent(getIntent());
    Bitmap back = intent.getParcelableExtra("back");
    BitmapDrawable ob = new BitmapDrawable(getResources(), back);
    getWindow().setBackgroundDrawable(ob);
    setContentView(R.layout.filter_activity);
}

But it force closed for me with this error in logcat:

03-08 14:03:54.685 16735-16735/ir.aftabeshafa.shafadoc E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 13225428)
03-08 14:03:54.685 16735-16735/ir.aftabeshafa.shafadoc D/AndroidRuntime: Shutting down VM
03-08 14:03:54.686 16735-16735/ir.aftabeshafa.shafadoc E/AndroidRuntime: FATAL EXCEPTION: main
                                                                         Process: ir.aftabeshafa.shafadoc, PID: 16735
                                                                         java.lang.RuntimeException: Failure from system

How can I fix this? Or do you know another way to blur the background of dialog activity?

Community
  • 1
  • 1

2 Answers2

0

Try this code snippet, this will create transparent background for Dialog.

private void Dialog() {
        final Dialog dialog = new Dialog(GenerateToken.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.customdialog_tokenvalidate);
        dialog.setCanceledOnTouchOutside(false);
        dialog.setCancelable(false);
        Window window = dialog.getWindow();
        window.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        window.setGravity(Gravity.CENTER);
        //The below code is EXTRA - to dim the parent view by 70%
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.dimAmount = 0.7f;
        lp.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
        dialog.getWindow().setBackgroundDrawable(new      ColorDrawable(android.graphics.Color.TRANSPARENT));
        dialog.getWindow().setAttributes(lp);
        //Show the dialog
        dialog.show();
        TextView tvSelectedBank = (TextView) dialog.findViewById(R.id.validatetext);
        //button for ok
        dialog.findViewById(R.id.tokenvalidate).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
                dialog.dismiss();
            }
        });
        dialog.show();
    }

also, get help from this thread Blur Background behind AlertDialog

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Sandeep Devhare
  • 440
  • 1
  • 6
  • 16
  • this code just transparent background not blur. you can do this just with this code in oncreate `getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));` –  Mar 08 '16 at 12:26
0

At first,you shouldn't translate Bitmap by Binder,the max container of binder is 1M.

You can try this: At first:

MyApplication. back2 = back2;

then:

   @Override
protected void onCreate(Bundle savedInstanceState) {
    BitmapDrawable ob = new BitmapDrawable(getResources(),MyApplication.back2);
    getWindow().getDecorView().setBackground(ob);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.filter_activity);
}
BinGoBinBin
  • 182
  • 11