天天看點

AlertDialog Unable to add window -- token null is not for an application

是因為 

AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
           
中 Builder雖然需要的是Context參數。但隻有在同一個activity中可以用
getApplicationContext() 得到Context 。      
否則要用Activity.this傳遞Context 即       
Builder(<span style="font-family: 宋體; font-size: 12pt; background-color: rgb(255, 255, 255);">Activity.this</span><span style="font-family: 宋體; font-size: 12pt;">)</span>