i have created live wallpaper in android 2.1.X , now i want to call this code in my activity so that user can set my created live wallpaper throug开发者_运维百科h button click just like "Set Wallpaper" button.
As my livewallpaper code extends WallpaperService class so that i can't even call as an intent.
Check this link. It shows the code for how to add a picker. It uses WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER which is api level 7, so check you are compiling against the correct version.
The code:
public class OpenActivity extends Activity { private int REQUEST_CODE = 1;
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Intent intent = new Intent(); intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER); startActivityForResult(intent, REQUEST_CODE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode,
resultCode, intent); if (requestCode == REQUEST_CODE) finish(); } }
精彩评论