2011-04-12 30 views

回答

1
try{   
    Class arcls = Class.forName("com.google.ads.AdRequest");   
    Constructor ct = arcls.getConstructor(new Class[0]);   
    Object adRequest = ct.newInstance();      
    Class avcls = Class.forName("com.google.ads.AdView");   

    //testmode 
    Method methTestMode = arcls.getMethod("setTesting", new Class[]{Boolean.TYPE}); 
    methTestMode.invoke(adRequest, new Object[]{new Boolean(true)});     
    //end testmode 

    Method methLoadAd = avcls.getMethod("loadAd", new Class[]{arcls});   
    Object adview = act.findViewById(R.id.adView);     
    methLoadAd.invoke(adview, new Object[]{adRequest});   
}catch (Exception e){}