Najaf Ali
Najaf Ali

Reputation: 1473

how i can set current date and time as wallpaper in android pragmatically?

i wants to set current date and time as a wall paper in android problematically. how it is possible kindly help me , thanks in advance.

Upvotes: 0

Views: 198

Answers (1)

kazmer1998
kazmer1998

Reputation: 23

Now you can call 'showCurrentTime();' whenever you want. Don't forget to update this every second! :)

void showCurrentTime() {
            final SurfaceHolder holder = getSurfaceHolder();
            Canvas c = null;
            try {
                c = holder.lockCanvas();
                if (c !=null) {
                    c.save();
                    c.drawColor(0xff000000);
                    c.drawText(new Date(System.currentTimeMillis()).toLocaleString(), mTouchX, mTouchY, mPaint);
                    c.restore();
                }
            } finally {
                if (c != null) {
                    holder.unlockCanvasAndPost(c);
                }
            }
        }

Upvotes: 1

Related Questions