protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (requestCode == IMAGE_PICK && resultCode == RESULT_OK) {
     if (data != null && data.getData() != null) {
       Uri uri = data.getData();
       addTemporaryWallpaperTile(uri, false);
     }
   } else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) {
     setResult(RESULT_OK);
     finish();
   } else if (requestCode == PICK_LIVE_WALLPAPER) {
     WallpaperManager wm = WallpaperManager.getInstance(this);
     final WallpaperInfo oldLiveWallpaper = mLiveWallpaperInfoOnPickerLaunch;
     final WallpaperInfo clickedWallpaper = mLastClickedLiveWallpaperInfo;
     WallpaperInfo newLiveWallpaper = wm.getWallpaperInfo();
     // Try to figure out if a live wallpaper was set;
     if (newLiveWallpaper != null
         && (oldLiveWallpaper == null
             || !oldLiveWallpaper.getComponent().equals(newLiveWallpaper.getComponent())
             || clickedWallpaper.getComponent().equals(oldLiveWallpaper.getComponent()))) {
       // Return if a live wallpaper was set
       setResult(RESULT_OK);
       finish();
     }
   }
 }
 protected void onRestoreInstanceState(Bundle savedInstanceState) {
   ArrayList<Uri> uris = savedInstanceState.getParcelableArrayList(TEMP_WALLPAPER_TILES);
   for (Uri uri : uris) {
     addTemporaryWallpaperTile(uri, true);
   }
   mSelectedIndex = savedInstanceState.getInt(SELECTED_INDEX, -1);
 }