Skip to content

Instantly share code, notes, and snippets.

@F0x1d F0x1d/code Secret
Created Oct 8, 2018

Embed
What would you like to do?
Загрузка:
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inMutable = true;
Bitmap b = null;
try {
InputStream ims = App.getInstance().getContentResolver().openInputStream(uri);
b = BitmapFactory.decodeStream(ims, null, bmOptions);
assert ims != null;
ims.close();
} catch (FileNotFoundException e) {
Toast.makeText(App.getInstance(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(App.getInstance(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
return new BitmapDrawable(App.getInstance().getResources(), b);
Выбор картинки:
if (requestCode == 228 && data != null){
// Toast.makeText(getActivity(), data.getData().toString(), Toast.LENGTH_SHORT).show();
SharedPreferences.Editor ed = PreferenceManager.getDefaultSharedPreferences(App.getInstance()).edit();
ed.putString("path1", data.getData().toString());
ed.apply();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.