本文整理汇总了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();
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
}
});
}
示例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();
}
}
示例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();
}
}
示例11: clearApplicationUserData
import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
/** @hide */
@Override public void clearApplicationUserData(String packageName, IPackageDataObserver observer) {
mBase.clearApplicationUserData(packageName, observer);
}
示例12: deleteApplicationCacheFiles
import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
/** @hide */
@Override public void deleteApplicationCacheFiles(String packageName, IPackageDataObserver observer) {
mBase.deleteApplicationCacheFiles(packageName, observer);
}
示例13: deleteApplicationCacheFilesAsUser
import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
/** @hide */
@Override public void deleteApplicationCacheFilesAsUser(String packageName, int userId, IPackageDataObserver observer) {
mBase.deleteApplicationCacheFilesAsUser(packageName, userId, observer);
}
示例14: freeStorageAndNotify
import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
/** @hide */
@Override public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
mBase.freeStorageAndNotify(freeStorageSize, observer);
}
示例15: clearApplicationUserData
import android.content.pm.IPackageDataObserver; //导入依赖的package包/类
@Override
public void clearApplicationUserData(String packageName, IPackageDataObserver observer) {
}