How do I launch the Preview/Select Wallpaper activ

2019-08-18 16:12发布

I think my question is fairly straight forward... how do I launch the standard activity for previewing my Live Wallpaper from within an Activity (of the same application)?

*Edit: In Logcat... here is the entry when you launch the intent I want to use...

04-06 09:44:08.369: INFO/ActivityManager(17452): Starting: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) } from pid 21944

2条回答
仙女界的扛把子
2楼-- · 2019-08-18 16:48

Do you mean something like this?

  1. Make an activity that holds the Live Wallpaper fullscreen
  2. Open that activity using:

    Intent i = new Intent(this, [Activityname]);
    startActivity(i);

查看更多
来,给爷笑一个
3楼-- · 2019-08-18 17:04

Hahaha.. This answer is coming a little late. ;-) But, I don't think it's been answered correctly yet so here goes... What I gather is that you want to launch the wallpaper chooser. There's two ways to do that depending on which android version, you'll see below. You can only specify YOUR wallpaper after version 16. Otherwise, you launch the chooser and the user specifies the wallpaper.

   if (android.os.Build.VERSION.SDK_INT >= 16)
    {
        Intent intent = new Intent("android.service.wallpaper.CHANGE_LIVE_WALLPAPER");
        intent.putExtra("android.service.wallpaper.extra.LIVE_WALLPAPER_COMPONENT", new ComponentName(getApplicationContext().getPackageName(), (new StringBuilder(String.valueOf(getApplicationContext().getPackageName()))).append(".LiveWallpaper").toString()));


        try
        {
            startActivity(intent);
            finish();
            return;
        }
        catch (ActivityNotFoundException activitynotfoundexception)
        {
            activitynotfoundexception.printStackTrace();
        }
        return;
    }
    Intent intent1 = new Intent();
    intent1.setAction("android.service.wallpaper.LIVE_WALLPAPER_CHOOSER");
    try
    {
        startActivity(intent1);
    }
    catch (ActivityNotFoundException activitynotfoundexception1)
    {
        activitynotfoundexception1.printStackTrace();
        Toast.makeText(getApplicationContext(), "Live Wallpapers not supported", 1).show();
    }
    finish();
查看更多
登录 后发表回答