1. 程式人生 > >Android 偶見方法記錄

Android 偶見方法記錄

1 Window 的getCallback()方法,返回當前視窗的當前Callback介面 Activity,Dialog中setCallback(this),傳當前Activity,dialog

 if (getWindow().getCallback() instanceof Activity){
       Log.e("Activity",""+getWindow().getCallback());
   }
    if (dialog.getWindow().getCallback() instanceof Dialog){
       Log.e("Dialog",""+dialog.getWindow().getCallback());//自定義的Dialog
 }
 列印:
 E/Activity: 
[email protected]
E/Dialog: [email protected]