Show AppCompatActivity as dialog programmatically
<p>I would like to show an Activity (use AppCompat) as Dialog when my device is a tablet.</p>

<p>Here is my theme for <em>MyAppCompatActivity</em></p>

<pre><code>&lt;style name="AppDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert"&gt;
    &lt;item name="windowNoTitle"&gt;true&lt;/item&gt;
&lt;/style&gt;
</code></pre>

<p>When I put directly this theme in my Manifest.xml like this, works fine : </p>

<pre><code>&lt;activity android:name=".MyAppCompatActivity" android:theme="@style/AppDialogTheme"/&gt;
</code></pre>

<p>But when I would like set my theme programmatically, my Activity appears as dialog but the background overlay is black (and not transparent as the first method). Here is my code :</p>

<pre><code>public abstract class MyAppCompatActivity extends AppCompatActivity 
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
         if(isTablet)
         {
             setTheme(R.style.AppDialogTheme);
         }

        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_layout);
    }
}
</code></pre>