2

I am trying to figure out if there is any mechanism to detect when a user clicks on Set Wallpaper or presses Back in the preview screen or if they pressed the back button. I have looked at the Wallpaper Service Engine and the only change I can make use of is to detect whether the user is in preview mode or not

I am wondering if anyone else ran it to this issue? Thanks in advance for your help: Here is a simple wallpaper engine that logs few events

@Override
    public void onCreate(SurfaceHolder surfaceHolder) {
        super.onCreate(surfaceHolder);
        Log.d(TAG, "onCreate");
        Log.d(TAG, "isPreview ... " + isPreview());
    }


@Override
    public void onSurfaceCreated(SurfaceHolder surfaceHolder) {
        Log.d(TAG, "onSurfaceCreated");
    }

    @Override
    public void onVisibilityChanged(boolean isVisible) {
        Log.d(TAG, "onVisibilityChanged .." + isVisible);
    }

    @Override
    public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
        Log.d(TAG, "onSurfaceChanged");
    }

    @Override
    public void onSurfaceRedrawNeeded(SurfaceHolder surfaceHolder) {
        Log.d(TAG, "onSurfaceRedrawNeeded");  
    }

    @Override
    public void onSurfaceDestroyed(SurfaceHolder surfaceHolder) {
        Log.d(TAG, "onSurfaceDestroyed");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy");

    }

1 Answers1

2

Alright just in case someone else runs into this issue. My solution was to: start the wallpaper preview activity with result:

Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName
                        (MyActivity.this, MyWallpaperService.class));
                startActivityForResult(intent, MY_REQUESTCODE);

When the user clicks "Set Wallpaper" you will receive an

 Activity.RESULT_OK

When the users clicks "Settings" you will receive

Activity.RESULT_CANCELED

Hope it helps