binderStub = new IRemoteStrviceStub();
}
@Nullable
安卓intent用法@Override
public IBinder onBind(Intent intent) {
return binderStub;
}
public class IRemoteStrviceStub extends IRemoteService.Stub {
@Override
public void memoryScan(IMemoryScanCallback iMemoryScanCallback) throws RemoteException {
synchronized (this) {
if (iMemoryScanCallback != null) {
}
doMemoryScan();
}
}
@Override
public void memoryClear(IMemoryClearCallback iMemoryClearCallback) throws RemoteException {
synchronized (this) {
if (iMemoryClearCallback != null) {
}
doMemoryClear();
}
}
}
/**
* 内存扫描
*/
private void doMemoryScan(){
if (memoryManager == null) {
memoryManager = Manager(getApplicationContext(), MemoryManager.class);
}
memoryManager.setCallback(new MemoryScanImpl() {
@Override
public void onReady() {
selectCallbackMethod(Const.MEMORY_SCAN, "onReady", null);
}
@Override
public void onUpdate(int progress, int max, String item) {
Class[] classes = new Class[]{int.class, int.class, String.class};
selectCallbackMethod(Const.MEMORY_SCAN, "onUpdate", classes, progress, max, item);
}
@Override
public void onResult(boolean isCanceled, long selectedSize, long size, List<AppPackageInfo> result) {
Class[] classes = new Class[]{boolean.class, long.class, long.class, List.class};
selectCallbackMethod(Const.MEMORY_SCAN, "onResult", classes, isCanceled, selectedSize, size, result);            }
}, null);
memoryManager.scan();
}
/**
* 内存清理
*/
private void doMemoryClear(){
if (memoryManager == null){
return;
}
memoryManager.setCallback(null, new MemoryClearImpl() {
@Override
public void onUpdate(int progress, int max, String item) {
Class[] classes = new Class[]{int.class, int.class, String.class};
selectCallbackMethod(Const.MEMORY_CLEAR, "onUpdate", classes, progress, max, item);

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。