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

时间:2017-11-13 06:33:34

标签: live-wallpaper

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.

1 个答案:

答案 0 :(得分:1)

现在您可以随时调用' showCurrentTime(); '。 不要忘记每秒更新一次!:)

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);
                }
            }
        }
相关问题