D/LoaderContactActivity: onCreateLoader() called with: id = [1], args = [null]
D/LoaderContactActivity: getLoaderManager():LoaderManager{b33365 in HostCallbacks{b13d83a}}
D/LoaderContactActivity: onLoadFinished() called with: loader = [CursorLoader{8573e06 id=1}], data = [android.content.ContentResolver$CursorWrapperInner@af6cc7]
然后旋转屏幕:
getLoaderManager():LoaderManager{b33365 in HostCallbacks{a0715b7}}
onLoadFinished() called with: loader = [CursorLoader{8573e06 id=1}], data = [android.content.ContentResolver$CursorWrapperInner@af6cc7]
public abstract class FragmentHostCallback extends FragmentContainer {
private final Activity mActivity;
final Context mContext;
private final Handler mHandler;
final int mWindowAnimations;
final FragmentManagerImpl mFragmentManager = new FragmentManagerImpl();
private ArrayMap mAllLoaderManagers;
private LoaderManagerImpl mLoaderManager;
private boolean mCheckedForLoaderManager;
private boolean mLoadersStarted;
.......}
final SparseArray mLoaders = new SparseArray(0);
void doStart() {
if (DEBUG) Log.v(TAG, "Starting in " + this);
if (mStarted) {
RuntimeException e = new RuntimeException("here");
e.fillInStackTrace();
Log.w(TAG, "Called doStart when already started: " + this, e);
return;
}
mStarted = true;
// 在这里调用所有Loader的start方法,
// Let the existing loaders know that we want to be notified when a load is complete
for (int i = mLoaders.size()-1; i >= 0; i--) {
mLoaders.valueAt(i).start();
}
}
void dispatchOnLoadComplete(LoadTask task, D data) {
if (mTask != task) {//如果任务已经改变,就不再交付数据了
if (DEBUG) Log.v(TAG, "Load complete of old task, trying to cancel");
dispatchOnCancelled(task, data);
} else {
if (isAbandoned()) {
// This cursor has been abandoned; just cancel the new data.
onCanceled(data);
} else {
commitContentChanged();
mLastLoadCompleteTime = SystemClock.uptimeMillis();
mTask = null;
if (DEBUG) Log.v(TAG, "Delivering result");
deliverResult(data);
}
}
}
public void deliverResult(D data) {
if (mListener != null) {
mListener.onLoadComplete(this, data);
}
}
public class AppLoader extends AsyncTaskLoader> {
private static final String TAG = AppLoader.class.getSimpleName();
private PackageManager mPackageManager;
private final AppComparator mAppComparator = new AppComparator();
private List mApps;
private PackageIntentReceiver mPackageReceiver;
public AppLoader(Context context) {
super(context);
mPackageManager = context.getPackageManager();
}
@Override
public List loadInBackground() {
return loadAppList();
}
private List loadAppList() {
List installedApplications = mPackageManager.getInstalledApplications(
PackageManager.GET_UNINSTALLED_PACKAGES);
if (Checker.isEmpty(installedApplications)) {
installedApplications = Collections.emptyList();
}
List appEntities = new ArrayList<>();
AppEntity entry;
for (ApplicationInfo app : installedApplications) {
entry = new AppEntity(app);
entry.initInfos(getContext(), mPackageManager);
appEntities.add(entry);
}
Collections.sort(appEntities, mAppComparator);
return appEntities;
}
private class AppComparator implements Comparator {
@Override
public int compare(AppEntity lhs, AppEntity rhs) {
if (lhs == rhs) {
return 0;
}
return lhs.getAppName().compareTo(rhs.getAppName());
}
}
@Override
public void deliverResult(List data) {
if (isReset()) {
if (!Checker.isEmpty(mApps)) {
onReleaseResources(data);
}
}
List oldData = data;
mApps = data;
if (isStarted()) {
super.deliverResult(mApps);
}
if (!Checker.isEmpty(oldData)) {
onReleaseResources(oldData);
}
}
protected void onReleaseResources(List apps) {
// For a simple List<> there is nothing to do. For something
// like a Cursor, we would close it here.
}
@Override
protected void onStartLoading() {
if (!Checker.isEmpty(mApps)) {
deliverResult(mApps);
}
if (mPackageReceiver == null)
mPackageReceiver = new PackageIntentReceiver(this);
if (takeContentChanged() || Checker.isEmpty(mApps)) {
forceLoad();
}
}
/**
* Handles a request to stop the Loader.
*/
@Override
protected void onStopLoading() {
// Attempt to cancel the current load task if possible.
cancelLoad();
}
/**
* Handles a request to cancel a load.
*/
@Override
public void onCanceled(List apps) {
super.onCanceled(apps);
// At this point we can release the resources associated with 'apps'
// if needed.
onReleaseResources(apps);
}
@Override
protected void onReset() {
stopLoading();
if (mPackageReceiver != null) {
getContext().unregisterReceiver(mPackageReceiver);
mPackageReceiver = null;
}
if (!Checker.isEmpty(mApps)) {
onReleaseResources(mApps);
mApps = null;
}
}
}
用于实现App卸载安装的广播接收者:
public class PackageIntentReceiver extends BroadcastReceiver {
final AppLoader mLoader;
private static final String TAG = PackageIntentReceiver.class.getSimpleName();
public PackageIntentReceiver(AppLoader loader) {
mLoader = loader;
IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
mLoader.getContext().registerReceiver(this, filter);
// Register for events related to sdcard installation.
IntentFilter sdFilter = new IntentFilter();
sdFilter.addAction(IntentCompat.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
sdFilter.addAction(IntentCompat.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
Log.d(TAG, "PackageIntentReceiver() called with: " + "loader = [" + loader + "]");
mLoader.getContext().registerReceiver(this, sdFilter);
}
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive() called with: " + "context = [" + context + "], intent = [" + intent + "]");
// 这里很重要哦,调用mLoader告知数据源改变了
mLoader.onContentChanged();
}
}
eclipse中使用maven插件的时候,运行run as maven build的时候报错
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
可以设一个环境变量M2_HOME指
1.建好一个专门放置MySQL的目录
/mysql/db数据库目录
/mysql/data数据库数据文件目录
2.配置用户,添加专门的MySQL管理用户
>groupadd mysql ----添加用户组
>useradd -g mysql mysql ----在mysql用户组中添加一个mysql用户
3.配置,生成并安装MySQL
>cmake -D
好久没有去安装过MYSQL,今天自己在安装完MYSQL过后用navicat for mysql去厕测试链接的时候出现了10061的问题,因为的的MYSQL是最新版本为5.6.24,所以下载的文件夹里没有my.ini文件,所以在网上找了很多方法还是没有找到怎么解决问题,最后看到了一篇百度经验里有这个的介绍,按照其步骤也完成了安装,在这里给大家分享下这个链接的地址
import java.io.UnsupportedEncodingException;
/**
* 转换字符串的编码
*/
public class ChangeCharset {
/** 7位ASCII字符,也叫作ISO646-US、Unicode字符集的基本拉丁块 */
public static final Strin
其实这个没啥技术含量,大湿们不要操笑哦,只是做一个简单的记录,简单用了一下递归算法。
import java.io.File;
/**
* @author Perlin
* @date 2014-6-30
*/
public class PrintDirectory {
public static void printDirectory(File f
linux安装mysql出现libs报冲突解决
安装mysql出现
file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.5.33-1.linux2.6.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686
Dear,
I'm pleased to announce that ktap release v0.1, this is the first official
release of ktap project, it is expected that this release is not fully
functional or very stable and we welcome bu