1
我試圖訪問谷歌使用這樣的Java反射方法播放服務類訪問谷歌播放服務類:問題在使用Java反射
Class<?> adIdClientClass;
try {
adIdClientClass = Class.forName("com.google.android.gms.ads.identifier.AdvertisingIdClient");
Method getAdvertisingIdInfoMethod = adIdClientClass.getDeclaredMethod("getAdvertisingIdInfo", Context.class);
Object o = getAdvertisingIdInfoMethod.invoke(null, this);
System.out.println(o);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但是,它抱怨不具有類的來源,我打電話使用反射。這裏是屏幕截圖:
所以有沒有辦法用反射執行谷歌播放服務類?