Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void loadBackground(SharedPreferences prefs) {
- background = null;
- String backgroundPath = null;
- try {
- backgroundPath = prefs.getString(
- getString(R.string.background_key), null);
- } catch (ClassCastException cce) {
- backgroundPath = "tmp";
- }
- if (backgroundPath != null) {
- InputStream is = null;
- try {
- is = openFileInput(getString(R.string.background_file));
- background = BitmapFactory.decodeStream(is);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (OutOfMemoryError oome) {
- Toast.makeText(getApplicationContext(),
- R.string.image_too_large_error, Toast.LENGTH_LONG)
- .show();
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- }
- }
- if (background == null) {
- background = BitmapFactory.decodeResource(getResources(),
- R.drawable.bg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement