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 8276839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:30:12+00:00 2026-06-08T08:30:12+00:00

I display an Alertbox with ok or cancel. I want to implement an asynch

  • 0

I display an Alertbox with ok or cancel.
I want to implement an asynch task on the press of OK. Havent done asynch and been struggling with it for awhile. I dont understand where the asych class goes also. Does it go outside the method that is being executed or outside of it? Current code as follows:

 private abstract  class DoAsynchTask extends AsyncTask<Void,Void,Void> 
 {
  protected  void doInBackground()
  {
   Drawable drawable= getImage(imageSelect);     
   MakeWallPaper(drawable,1);
  }

  /* protected void onProgressUpdate(Integer... progress) 
  {
   setProgress(progress[0]);
  }*/

  protected void onPostExecute() 
  {
   Toast.makeText(getApplicationContext(), "Wallpaper Saved.",Toast.LENGTH_LONG).show();      
   AlertDialogProcessing=0;
  }
 }

 public void getWallpaper(final View v)
 {
  if(AlertDialogProcessing==0)
  {  
   final String title="Set Image to Wallpaper";
   final String message="Press OK to set as Wallpaper or CANCEL.\nWait after pushing OK.";
   final String ok="OK";
   final String cancel="CANCEL";
   final AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
   alertbox.setCancelable(true);
   alertbox.setIcon(android.R.drawable.ic_dialog_alert);
   alertbox.setTitle(title);
   alertbox.setMessage(message);
   alertbox.setNegativeButton(cancel, null);
   final AlertDialog dlg = alertbox.create();

   alertbox.setPositiveButton(ok,new DialogInterface.OnClickListener()
   {  
     public void onClick(DialogInterface dlg, int which)
     {  
       DoAsynchTask.execute(null,null,null);  //<<<<Wrong
       dlg.dismiss();
       Vibrate(ClickVibrate); 
     } 
    });
    alertbox.setNegativeButton(cancel,new DialogInterface.OnClickListener(){ public  void onClick(DialogInterface arg0, int arg1){AlertDialogProcessing=0;                     
     Vibrate(ClickVibrate); } });
 alertbox.show();
    }
   }
  • 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-06-08T08:30:14+00:00Added an answer on June 8, 2026 at 8:30 am

    There’s a couple problems in the code.

    1) First of all, the compiler is probably giving you this message:

    The type MyActivity.DoAsynchTask must implement the inherited abstract
    method
    AsyncTask.doInBackground(Void…) MyActivity.java

    If you look closely at the error message, you’ll realize that what you defined was this:

    protected  void doInBackground() {
    

    which is not what is needed. Even though it might seem silly, when your AsyncTask subclass takes Void as the generic parameter types, that means that doInBackground() must look like this:

    protected Void doInBackground(Void... arg0) {
    

    The compiler complains because you haven’t implemented that (exact) method. When you inherit from an abstract class, and fail to implement all of its required/abstract method(s), then you can only get it to compile by marking the subclass as abstract, too. But, that’s not really what you want.

    So, just change your code to (remove abstract from your class):

    private class DoAsynchTask extends AsyncTask<Void,Void,Void> 
    

    and

    protected Void doInBackground(Void... arg0) {
    {
       Drawable drawable= getImage(imageSelect);     
       MakeWallPaper(drawable,1);
       return null;
    }
    

    2) And the second problem, as others have pointed out, is that you must start your task with:

    new DoAsynchTask().execute();
    

    not

    DoAsynchTask.execute(null,null,null);   
    

    Your code would only be correct if execute() was a static method in AsyncTask, which it’s not. In order to invoke the non-static execute() method, you first need a new instance of the DoAsynchTask class. Finally, the null, null, null parameter list is also not necessary, although I don’t think it will cause the code to fail either.

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

Sidebar

Related Questions

I want to display an alert box multiple times with a button click event
I want to display a form in a Div, in alert box. How would
So, I have the code, its not done, but all i want it to
I can't see any error in my code. However, the Alertbox doesn't display when
I want to display the alert box but for a certain interval. Is it
How do i display a countdown timer in my alert box .i want to
Please help me, I want to display the position of a radio button when
I have been struggling with this for a few days. I need somebody to
Seems there is several variations on this theme. I display an AlertBox to the
Okay, after a successful user login, an alertbox will display the username and then

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.