2015-08-17 82 views
1
public class FingerprintManager { 

    * @hide 
    */ 
    // this class is hidden 
    public static abstract class EnrollmentCallback { 

     public void onEnrollmentError(int errMsgId, CharSequence errString) { } 


     public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) { } 


     public void onEnrollmentProgress(int remaining) { } 
    }; 
} 

EnrollmentCallback類是hidden.Is有沒有辦法通過反射來實例化EnrollmentCallback類,這是等同於:通過實例化一個反思靜態抽象類

EnrollmentCallback callbackObject = new EnrollmentCallback() 
{ 
     public void onEnrollmentError(int errMsgId, CharSequence errString) { } 


     public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) { } 


     public void onEnrollmentProgress(int remaining) { } 
}; 

回答

2

號可能可以做到這一點與一個字節碼操作庫(如ASM),但不能實例化一個abstract類而不擴展它並實現任何缺失的方法(abstract)。而且你不能用Java反射來做到這一點。