2013年9月8日星期日

Android Monitor network status, broken nets error: Unable toinstantiate the object

Monitoring is the use of radio receivers, registration code and the way to have used the manifest file.

public class ConnectivityReceiver extends BroadcastReceiver {

}

error are:
Unable to instantiate receiver xxx.ConnectivityReceiver:
java.lang.InstantiationException: xxx.ConnectivityReceiver
------ Solution ------------------------- -------------------
ConnectivityReceiver how to initialize an instance of an object it? The code stickers out

------ Solution ------------------------------------ --------

          
public ConnectivityReceiver (XxxService service) {           
this.service = service;           
}          
        
        
broadcast constructor can be so?        
      
      
      
no arguments, how to pass variables that need to come in? ? ?      
    
    
you first see if I can try to remove the initialization    
  
  
  
can be removed, but I did not need a variable value ah  

You will not take the initiative to call XxxService get an instance of it ah
------ reference ------------------------- --------------


public ConnectivityReceiver (XxxService service) {
this.service = service;
}
------ reference ----------------------------------- ----


broadcast because it is registered, when the broken network, it will automatically receive the code, so it should be customized instantiate the object, and then calls to the receive code
------ reference - --------------------------------------

  
public ConnectivityReceiver (XxxService service) {   
this.service = service;   
}  

broadcast constructor can do is this?
------ reference -------------------------- -------------

    
public ConnectivityReceiver (XxxService service) {     
this.service = service;     
}    
  
  
broadcast constructor can be so?  


no arguments, how to pass variables that need to come in? ? ?
------ reference --------------------------------------- < br>
      
public ConnectivityReceiver (XxxService service) {       
this.service = service;       
}      
    
    
broadcast constructor can be so?    
  
  
  
no arguments, how to pass variables that need to come in? ? ?  

you first see if I can try to remove the initialization
------ reference --------------------------- ------------

        
public ConnectivityReceiver (XxxService service) {         
this.service = service;         
}        
      
      
broadcast constructor can be so?      
    
    
    
no arguments, how to pass variables that need to come in? ? ?    
  
  
you first see if I can try to remove the initialization  


can be removed, but I did not need a variable value ah
------ reference ------------------------- --------------
Well

------ reference - --------------------------------------

------ reference ---------- -----------------------------

没有评论:

发表评论