I am checking the internet connection in my application, when the internet is not accessible I want to display a small popup message to the user that you're offline.

I tried to solve the issue by using `AlertDialog` and `AlertDialog.Builder`, and I have also searched through different solution on the internet but no solution resolve my issue. I am trying to do this by the following method.

```
AlertDialog.Builder builder = new AlertDialog.Builder(context);
        LayoutInflater inflater = LayoutInflater.from(context);
        View alertdialog = inflater.inflate(R.layout.nointernetdialogue, null);
        builder.setView(alertdialog);
AlertDialog dialog = builder.create();
        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        WindowManager.LayoutParams alertTop = dialog.getWindow().getAttributes();
        alertTop.gravity = Gravity.TOP | Gravity.START;
        alertTop.x = 100;
        alertTop.y = 100;
        dialog.show();

```

The result I want.

[![](https://i.stack.imgur.com/ujPSY.png)](https://i.stack.imgur.com/ujPSY.png)