2011-07-28 14 views
2

我已經看到了如何在API中使用隱藏方法?

/** @hide */ 
public void setDiscoverableTimeout(int timeout) { 
    if (getState() != STATE_ON) return; 
    try { 
     mService.setDiscoverableTimeout(timeout); 
    } catch (RemoteException e) {Log.e(TAG, "", e);} 
} 

我想用上面的方法,但仍然不知道,我怎麼能在我的程序使用此方法,使我的應用程序也應該會常常發現模式的一些隱藏的方法呢?

+0

也許這個博客是有幫助的: [http://blog.codetastrophe.com/2008/12/accessing-hidden-system-service-apis-in.html](http://blog.codetastrophe.com/ 2008/12/access-hidden-system-service-apis-in.html) – accuya

回答

0

你可以使用反射,我一直在使用它。唯一不足的是它可能是谷歌沒有提供任何保證。

+0

如何使用它和Naresh我無法解決這個問題,我一直想要我的android藍牙發現,yar該怎麼辦? –

+0

Class c = Class.forName(android.bluetooth.BluetoothClass.Service);方法method = c.getMethodByName(「不管你想要什麼方法名稱」); method.invoke(mService,args ..)上面是一個示例代碼 – Naresh

+0

讓我試試Naresh,你能幫我多一點親愛的,這是我的第一個Android項目,並且需要一點幫助:-( –