【问题标题】:Start a live wallpaper service from activity从活动启动动态壁纸服务
【发布时间】:2012-01-31 14:32:48
【问题描述】:
public class ShortCurActivity extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final Button button = (Button)findViewById(R.id.b_start);
    if(button != null){
     button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View paramView) {
            Intent i = new Intent(ShortCurActivity.this, ServiceWallpaper.class);
                     startService(i);
        }
     });
    }

}

我只是想知道我是否可以从 Activity 启动动态壁纸服务。我曾尝试使用 Intent,但它不起作用。一些设计师希望我为动态壁纸制作快捷方式,以便用户可以随时更改动态壁纸:(

【问题讨论】:

    标签: android service android-service live-wallpaper android-activity


    【解决方案1】:
     if (Build.VERSION.SDK_INT > 15)
                {
                    i.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
                    String pkg = WallpaperService.class.getPackage().getName();
                    String cls = WallpaperService.class.getCanonicalName();
                    i.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName(pkg, cls));
                }
                else
                {
                    i.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
                }
                startActivityForResult(i, 0);``
    

    【讨论】:

      【解决方案2】:

      似乎没有任何方法可以以编程方式更改用户的 lwp。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多