【问题标题】:how can a broadcast receiver get the android system to start a livewallpaper service?广播接收器如何让安卓系统启动动态壁纸服务?
【发布时间】:2011-05-12 16:35:09
【问题描述】:

LiveWallpapers 拥有 BIND_WALLPAPER 权限,只允许系统绑定到它。我希望在设备启动时将 livewallpaper 服务设置为壁纸。为此,我编写了一个广播接收器,它在启动时使用意图启动壁纸服务。动态壁纸的组件被设置为意图的组件。目前这可以检测到壁纸服务,但由于权限 BIND_WALLPAPER 无法设置它。我的应用程序清单包括以下内容

<receiver android:name=".MyStartupIntentReceiver" android:permission="android.permission.BIND_WALLPAPER">
        <intent-filter>
             <action android:name="android.intent.action.BOOT_COMPLETED" />
             <category android:name="android.intent.category.HOME" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SET_WALLPAPER" />
            <category android:name="android.intent.category.HOME"/>
        </intent-filter>           
    </receiver>

广播接收器如下:

Intent ii = new Intent(Intent.ACTION_MAIN);
    ii.addCategory(Intent.CATEGORY_HOME);

    ii.setComponent(new ComponentName("com.example.android.livecubes","com.example.android.livecubes.cube1.CubeWallpaper1"));
    context.startService(ii);

我也用 action.SET_WALLPAPER...category 尝试了上述操作:启动器/默认,但一切都抛出错误权限被拒绝:需要绑定壁纸。此权限存在于服务端和接收端。如何在没有选择器/动态壁纸选择器的情况下在启动时设置动态壁纸?

【问题讨论】:

    标签: android live-wallpaper


    【解决方案1】:

    这是不可能的。您可以启动选择器,但不能绕过选择器并以无缝方式实际设置壁纸。请在此处查看 Romain Guy 的评论:http://groups.google.com/group/android-developers/browse_thread/thread/a22e66002f884718

    【讨论】:

    • 感谢您的回复。这可以通过查看 android 操作系统是如何做到的吗?我想看android os源码,你有什么建议吗?
    • @SDLBING 我的理解是应用程序程序员确实不可能做到这一点。它不是“公共”API 的一部分。换句话说,它需要一个我们不可能得到的“许可”。您可以查看选择器的功能,但您无法复制其方法。我拥有的最好的“证据”是我从未见过有人让它起作用。例如,aniPet 水族馆动态壁纸带有一个应用程序来方便设置壁纸,但它所做的只是启动选择器。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多