古いものですが、まだ誰もそれに答えていません。リフレクションAPIを使用すると、すべての非表示クラスを使用できます。ここでは、リフレクションAPIを介してService Managerを使用してサービスを取得する例を示します。
if(mService == null) {
Method method = null;
try {
method = Class.forName("android.os.ServiceManager").getMethod("getService", String.class);
IBinder binder = (IBinder) method.invoke(null, "My_SERVICE_NAME");
if(binder != null) {
mService = IMyService.Stub.asInterface(binder);
}
if(mService != null)
mIsAcquired = true;
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
} else {
Log.i(TAG, "Service is already acquired");
}
私はこのServiceManagerクラスをアプリケーションで使用することはできません。 –