OnTouchListener活动意图壁纸服务

时间:2015-06-29 04:55:20

标签: android

我的活动

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
...
}

public void openService(View view) {
    Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
    intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName(this, mWallpaperService.class));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    finish();
}

mWallpaperService

public class mWallpaperService extends WallpaperService {
@Override
public Engine onCreateEngine() {
    return new mEngine();
}

private class mEngine extends Engine {
    ...
    @Override
    public void onTouchEvent(MotionEvent event) {
    ...
    }
}

我在onTouchEvent中获取事件就是它的描述

     /**
     * Called as the user performs touch-screen interaction with the
     * window that is currently showing this wallpaper.  Note that the
     * events you receive here are driven by the actual application the
     * user is interacting with, so if it is slow you will get fewer
     * move events.
     */
     public void onTouchEvent(MotionEvent event) {
     }

我认为我正在失去一些触摸事件,我的问题是如何添加原始OnTouchListener的?

我试图将implements View.OnTouchListener添加到所有类中,但没有运气,我没有注册新的监听器。

0 个答案:

没有答案