当前位置: 首页>>代码示例>>Java>>正文


Java IPackageDataObserver类代码示例

本文整理汇总了Java中android.content.pm.IPackageDataObserver的典型用法代码示例。如果您正苦于以下问题:Java IPackageDataObserver类的具体用法?Java IPackageDataObserver怎么用?Java IPackageDataObserver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IPackageDataObserver类属于android.content.pm包,在下文中一共展示了IPackageDataObserver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProvide

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
public static void testProvide() {
    IPackageDataObserver packageDataObserver = new IPackageDataObserver() {
        @Override
        public void onRemoveCompleted(String s, boolean b) throws RemoteException {
            doHeavyWork();
            doHeavyWork();
        }

        @Override
        public IBinder asBinder() {
            return null;
        }
    };
    try {
        packageDataObserver.onRemoveCompleted("haha", false);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
    doHeavyWork();
}
 
开发者ID:seiginonakama,项目名称:BlockCanaryEx,代码行数:21,代码来源:TestUtil.java

示例2: doInBackground

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
@Override protected Long doInBackground(Void... params) {
    final CountDownLatch countDownLatch = new CountDownLatch(1);

    StatFs stat = new StatFs(
            Environment.getDataDirectory().getAbsolutePath());

    try {
        mFreeStorageAndNotifyMethod.invoke(getPackageManager(),
                (long) stat.getBlockCount() *
                        (long) stat.getBlockSize(),
                new IPackageDataObserver.Stub() {
                    @Override
                    public void onRemoveCompleted(String packageName, boolean succeeded)
                            throws RemoteException {
                        countDownLatch.countDown();
                    }
                });

        countDownLatch.await();
    } catch (InvocationTargetException | InterruptedException | IllegalAccessException e) {
        e.printStackTrace();
    }

    return mCacheSize;
}
 
开发者ID:towavephone,项目名称:MemoryCleaner,代码行数:26,代码来源:CleanerService.java

示例3: onCreate

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
@Override public void onCreate() {
    try {
        mGetPackageSizeInfoMethod = getPackageManager().getClass()
                                                       .getMethod(
                                                               "getPackageSizeInfo",
                                                               String.class,
                                                               IPackageStatsObserver.class);

        mFreeStorageAndNotifyMethod = getPackageManager().getClass()
                                                         .getMethod(
                                                                 "freeStorageAndNotify",
                                                                 long.class,
                                                                 IPackageDataObserver.class);
        mDeleteApplicationCacheFiles = getPackageManager().getClass()
                                                          .getMethod(
                                                                  "deleteApplicationCacheFiles",
                                                                  String.class,
                                                                  IPackageDataObserver.class);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
}
 
开发者ID:towavephone,项目名称:MemoryCleaner,代码行数:23,代码来源:CleanerService.java

示例4: clearAllCache

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
/**
 * clear all app cache
 * @param context
 * @param listener the completion listener, it can be null if you don't care the result.
 *                 onClearCompleted run on child thread.
 *                 onClearFailed run on UI thread.
 */
public static void clearAllCache(Context context, final ClearCacheListener listener) {
    /*
    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
        freeStorageAndNotify(null, freeStorageSize, observer);
    }
     */
    PackageManager pm = context.getPackageManager();
    try {
        Method freeStorageAndNotify = pm.getClass().getDeclaredMethod("freeStorageAndNotify", long.class, IPackageDataObserver.class);
        freeStorageAndNotify.invoke(pm, Long.MAX_VALUE, new IPackageDataObserver.Stub(){
            @Override
            public void onRemoveCompleted(String packageName, boolean succeeded) throws RemoteException {
                if(null != listener)
                    listener.onClearCompleted();
            }
        });

    } catch (Exception e) {
        e.printStackTrace();
        if(null != listener)
            listener.onClearFailed();
    }
}
 
开发者ID:ittianyu,项目名称:MobileGuard,代码行数:31,代码来源:AppManagerEngine.java

示例5: doInBackground

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
@Override
protected Long doInBackground(Void... params) {
    final CountDownLatch countDownLatch = new CountDownLatch(1);

    StatFs stat = new StatFs(Environment.getDataDirectory().getAbsolutePath());

    try {
        mFreeStorageAndNotifyMethod.invoke(getPackageManager(),
                (long) stat.getBlockCount() * (long) stat.getBlockSize(),
                new IPackageDataObserver.Stub() {
                    @Override
                    public void onRemoveCompleted(String packageName, boolean succeeded)
                            throws RemoteException {
                        countDownLatch.countDown();
                    }
                }
        );

        countDownLatch.await();
    } catch (InvocationTargetException | InterruptedException | IllegalAccessException e) {
        e.printStackTrace();
    }

    return mCacheSize;
}
 
开发者ID:KouChengjian,项目名称:PhoneMate,代码行数:26,代码来源:CleanerService.java

示例6: cleanAll

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
/**
 * ����¼���һ��������
 */
public void cleanAll(View view) {
	try {
		Method method = PackageManager.class.getDeclaredMethod(
				"freeStorageAndNotify", long.class,
				IPackageDataObserver.class);
		// ����Ҫ�ͷŵĿռ��С
		long localLong = Long.valueOf(getEnviromenSize() - 1L);
		// method.invoke(pm, localLong, new MyIPackageDataObserver());
		// ֱ�Ӹ�һ��Long.MAX_VALUEҲ��
		method.invoke(pm, Long.MAX_VALUE, new MyIPackageDataObserver());
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	Toast.makeText(context, "ȫ��������", Toast.LENGTH_LONG).show();
	fillData();
}
 
开发者ID:yoxin,项目名称:safety,代码行数:21,代码来源:CleanCacheActivity.java

示例7: call

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    if (args[args.length - 1] instanceof IPackageDataObserver) {
        IPackageDataObserver observer = (IPackageDataObserver) args[args.length - 1];
        observer.onRemoveCompleted(null, true);
    }
    return 0;
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:9,代码来源:MethodProxies.java

示例8: initUI

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
private void initUI() {
	bt_clear = (Button) findViewById(R.id.bt_clear);
	pb_bar = (ProgressBar) findViewById(R.id.pb_bar);
	tv_name = (TextView) findViewById(R.id.tv_name);
	ll_add_text = (LinearLayout) findViewById(R.id.ll_add_text);
	
	bt_clear.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			//1.��ȡָ������ֽ����ļ�
			try {
				Class<?> clazz = Class.forName("android.content.pm.PackageManager");
				//2.��ȡ���÷�������
				Method method = clazz.getMethod("freeStorageAndNotify", long.class,IPackageDataObserver.class);
				//3.��ȡ������÷���
				method.invoke(mPm, Long.MAX_VALUE,new IPackageDataObserver.Stub() {
					@Override
					public void onRemoveCompleted(String packageName, boolean succeeded)
							throws RemoteException {
						//���������ɺ���õķ���(����Ȩ��)
						Message msg = Message.obtain();
						msg.what = CLEAR_CACHE;
						mHandler.sendMessage(msg);
					}
				});
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}
 
开发者ID:cckevincyh,项目名称:mobilesafe,代码行数:32,代码来源:CacheClearActivity.java

示例9: onCreate

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
@Override
public void onCreate() {
	try {
		mGetPackageSizeInfoMethod = getPackageManager().getClass()
				.getMethod("getPackageSizeInfo", String.class,
						IPackageStatsObserver.class);

		mFreeStorageAndNotifyMethod = getPackageManager().getClass()
				.getMethod("freeStorageAndNotify", long.class,
						IPackageDataObserver.class);
	} catch (NoSuchMethodException e) {
		e.printStackTrace();
	}
}
 
开发者ID:KouChengjian,项目名称:PhoneMate,代码行数:15,代码来源:CleanerService.java

示例10: onCreate

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
@Override
public void onCreate() {
    try {
        mGetPackageSizeInfoMethod = getPackageManager().getClass().getMethod(
                "getPackageSizeInfo", String.class, IPackageStatsObserver.class);

        mFreeStorageAndNotifyMethod = getPackageManager().getClass().getMethod(
                "freeStorageAndNotify", long.class, IPackageDataObserver.class);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Frozen-Developers,项目名称:android-cache-cleaner,代码行数:13,代码来源:CleanerService.java

示例11: clearApplicationUserData

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
/** @hide */
@Override public void clearApplicationUserData(String packageName, IPackageDataObserver observer) {
	mBase.clearApplicationUserData(packageName, observer);
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:5,代码来源:PackageManagerWrapper.java

示例12: deleteApplicationCacheFiles

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
/** @hide */
@Override public void deleteApplicationCacheFiles(String packageName, IPackageDataObserver observer) {
	mBase.deleteApplicationCacheFiles(packageName, observer);
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:5,代码来源:PackageManagerWrapper.java

示例13: deleteApplicationCacheFilesAsUser

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
/** @hide */
@Override public void deleteApplicationCacheFilesAsUser(String packageName, int userId, IPackageDataObserver observer) {
	mBase.deleteApplicationCacheFilesAsUser(packageName, userId, observer);
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:5,代码来源:PackageManagerWrapper.java

示例14: freeStorageAndNotify

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
/** @hide */
@Override public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
	mBase.freeStorageAndNotify(freeStorageSize, observer);
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:5,代码来源:PackageManagerWrapper.java

示例15: clearApplicationUserData

import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
@Override
public void clearApplicationUserData(String packageName, IPackageDataObserver observer) {

}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:5,代码来源:StubPackageManager.java


注:本文中的android.content.pm.IPackageDataObserver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。