如何从活动内部启动我的壁纸的预览/选择壁纸活动?

发布于 2024-10-30 17:48:38 字数 241 浏览 4 评论 0原文

我认为我的问题相当简单......我如何启动标准活动来从活动(同一应用程序)中预览我的动态壁纸?

*编辑:在Logcat中...这是启动我想使用的意图时的条目...

04-06 09:44:08.369:INFO/ActivityManager(17452):启动:Intent { cmp=com.android. pid.livepicker/.LiveWallpaperPreview(有额外内容)} 来自 pid 21944

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Smile简单爱 2024-11-06 17:48:38

你的意思是这样的吗?

  1. 创建一个使动态壁纸全屏显示的活动
  2. 使用以下方式打开该活动:

    意图 i = new Intent(this, [活动名称]);
    startActivity(i);

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

夏天碎花小短裙 2024-11-06 17:48:38

哈哈哈..这个答案来得有点晚了。 ;-) 但是,我认为它还没有得到正确的回答,所以这里...我收集到的是您想要启动壁纸选择器。根据 Android 版本的不同,有两种方法可以实现此目的,如下所示。您只能在版本 16 之后指定您的壁纸。否则,您将启动选择器并由用户指定壁纸。

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

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文