How do you create a transparent activity that can overlay the home screen but is not dismissed when the home or back button is pressed?

You can create a transparent activity with the help of

  1. Make the background of layout in your xml file transparent by using

    android:background="@android:color/transparent

  2. And also, make the theme in your manifest file transparent for that particular activity

    <activity android:name="Your activity" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"> </activity>

  3. And for back press override the onBackPressed() method and remove super.onBackPressed()

    @Override
     public void onBackPressed()
      {
        // TODO Auto-generated method stub
      }
    

You can use the below codes..it worked for me except it don't let apps to be installed from the internal storage..

LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View oView = layoutInflater.inflate(R.layout.activity_transperant, null);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
        WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
        0 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
        PixelFormat.TRANSLUCENT);        
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(oView, params);