Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7567919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:47:24+00:00 2026-05-30T14:47:24+00:00

Welcome. I have a problem. I want to do dynamic wallpaper so that every

  • 0

Welcome. I have a problem. I want to do dynamic wallpaper so that every few seconds to change the text. The program works pretty well because the text is changing, but changing so that the previous text is still visible, and after a few seconds I have a lot of the text. I looked everywhere but I am a beginner and do not know how to solve that problem. There is a code:

private class MyWallpaperEngine extends Engine {  
    private final Handler handler = new Handler();  
    private final Runnable drawRunner = new Runnable() {  
        @Override  
        public void run() {
            draw();  
        }
    };  

    private Paint paint = new Paint();  
    private int width;
    int height;  
    private boolean visible = true;

    public MyWallpaperEngine() {  
        paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(Color.WHITE);
        handler.post(drawRunner);  
    }

    @Override  
    public void onVisibilityChanged(boolean visible) {  
        this.visible = visible;  
        if (visible) {  
            handler.post(drawRunner);  
        } else {  
            handler.removeCallbacks(drawRunner);  
        }
    }

    @Override  
    public void onSurfaceDestroyed(SurfaceHolder holder) {  
        super.onSurfaceDestroyed(holder);  
        this.visible = false;  
        handler.removeCallbacks(drawRunner);  
    }  

    @Override  
    public void onSurfaceChanged(SurfaceHolder holder, int format,  
            int width, int height) {  
        this.width = width;  
        this.height = height;  
        super.onSurfaceChanged(holder, format, width, height);  
    }  

    private void draw() {  
        SurfaceHolder holder = getSurfaceHolder();  
        Canvas canvas = null;
        try {  
            canvas = holder.lockCanvas();  
            if (canvas != null)
                drawAnimation(canvas);

        } finally {
            if (canvas != null)
                holder.unlockCanvasAndPost(canvas);

        }
        if (visible) {
            handler.postDelayed(drawRunner, 4000);  
        }
    }
    private void drawAnimation(Canvas c){
        Random r = new Random();
        int i1=r.nextInt(200-50) + 50;
        String text = Integer.toString(i1);
        c.drawText(text, i1, i1, paint);
    }
}  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:47:26+00:00Added an answer on May 30, 2026 at 2:47 pm

    You should clear the canvas before drawing, using something like

    c.drawColor(int color);
    

    or draw anything else that covers the entire area, otherwise you will just draw onto what was already on the canvas.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem. I have some text within a javascript. I want
Welcome! I have a recursive public static method named less that takes a tree
Welcome, I notice that Youtube make some changes into their website code. Anyone have
I have a reporting module in an ASP.NET webforms app (C#) that uses dynamic
I have a problem with my facelets: I constricted a nav part that displays
I have set up a Deployment Project for my application. The problem is that
I have a string like Welcome to McDonalds®: I'm loving it™ ... I want
My problem is that I want to know how many connections are opened to
I have an update service that starts at boot. The thing is I want
i have the problem when i want to update element in activity with intent.actually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.