Advertisement
Guest User

Untitled

a guest
Jul 31st, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1.     private void loadBackground(SharedPreferences prefs) {
  2.         background = null;
  3.         String backgroundPath = null;
  4.         try {
  5.         backgroundPath = prefs.getString(
  6.             getString(R.string.background_key), null);
  7.         } catch (ClassCastException cce) {
  8.         backgroundPath = "tmp";
  9.         }
  10.         if (backgroundPath != null) {
  11.         InputStream is = null;
  12.         try {
  13.             is = openFileInput(getString(R.string.background_file));
  14.             background = BitmapFactory.decodeStream(is);
  15.         } catch (FileNotFoundException e) {
  16.             e.printStackTrace();
  17.         } catch (OutOfMemoryError oome) {
  18.             Toast.makeText(getApplicationContext(),
  19.                 R.string.image_too_large_error, Toast.LENGTH_LONG)
  20.                 .show();
  21.         } finally {
  22.             if (is != null) {
  23.             try {
  24.                 is.close();
  25.             } catch (IOException e) {
  26.             }
  27.             }
  28.         }
  29.         }
  30.         if (background == null) {
  31.         background = BitmapFactory.decodeResource(getResources(),
  32.             R.drawable.bg);
  33.         }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement