How do I launch the Preview/Select Wallpaper activity for my Wallpaper from inside an Activity?

风流意气都作罢 提交于 2019-12-13 18:43:55

问题


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


回答1:


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);




回答2:


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();


来源:https://stackoverflow.com/questions/5547769/how-do-i-launch-the-preview-select-wallpaper-activity-for-my-wallpaper-from-insi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!