Code example for Preference

Methods: getKeysetIcon

0
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode != Activity.RESULT_OK) return;
        switch (requestCode) {
            case CUSTOM_USER_ICON:
                if (resultCode == Activity.RESULT_OK) {
                    String packageName = mPreference.getKey();
                    File image = new File(getActivity().getFilesDir() + File.separator
                            + "lockscreen_" + System.currentTimeMillis() + ".png");
                    String path = image.getAbsolutePath();
                    if (mImageTmp.exists()) {
                        mImageTmp.renameTo(image);
                    } 
                    image.setReadOnly();
                    modifyApplication(packageName, path);
                    Drawable icon = getDrawable(path);
                    if(icon != null) mPreference.setIcon(icon);
                } else { 
                    if (mImageTmp.exists()) {
                        mImageTmp.delete();
                    } 
                }