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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:28:29+00:00 2026-05-17T22:28:29+00:00

In my android application i am using a loading screen,processed by Async task.In do

  • 0

In my android application i am using a loading screen,processed by Async task.In do in background of this task i would like to display a alert whenever an upgraded version exist in the server.
Could you please let me know if there is any way that i can do it in android.

The code is

public class Task extends AsyncTask {

    // can use UI thread here
    protected void onPreExecute() {
        // this.dialog.setMessage("Loading...");
        prgbar.setVisibility(View.VISIBLE);
        // this.dialog.show();
    }

    @Override
    protected Void doInBackground(Void... params) {
        try {
                final UpGradation upgrade=(UpGradation) ParserServiceImpl.getUpgrade(); //check this method name correctly.
                if(upgrade != null)
                {

                    try {
                        pInfo = getPackageManager().getPackageInfo("com.docomo.aptv", PackageManager.GET_META_DATA);
                        String temp = pInfo.versionName;
                       int pversion= pInfo.versionCode;
                       int upversion=Integer.parseInt(upgrade.getVersion());
                       Log.i("VALUE RETURNED",""+pversion);
                        Log.i("jayantha","version name"+pInfo.versionName);
                        Log.i("jayanth","version code"+pInfo.versionCode);

                       if(pversion!=upversion)
                        {

                            final AlertDialog alert = new AlertDialog.Builder(context).create();
                            alert.setTitle("Updates");
                            alert.setMessage("An updated version of the application is present.Do you wish to download.");

                             alert.setButton("OK", new DialogInterface.OnClickListener() {
                                      public void onClick(DialogInterface dialog, int which) {

                                    alert.dismiss();
                                        Intent i = new Intent(Intent.ACTION_VIEW); 
                                        i.setData(Uri.parse(upgrade.getURL().trim())); 
                                        startActivity(i); 
                                        finish();

                                   } }); 
                             alert.setButton2("Cancel",
                                        new DialogInterface.OnClickListener() {
                                            public void onClick(
                                                    DialogInterface dialog,
                                                    int which) {
                                                return;
                                            }
                                        });

                            alert.setIcon(R.drawable.application_icon_50x50);
                            alert.setCancelable(false);
                            alert.show();


                           }
                      } 


                     catch (NameNotFoundException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }

Please forward your suggestions.

Thanks in advance 🙂

  • 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-17T22:28:29+00:00Added an answer on May 17, 2026 at 10:28 pm

    You cannot show alerts and dialogs from to doInBackground() method. us the postProgress() and do it in the onProgressUpdate() or wait for the afterExecuted() to do those things from the main UI thread.

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

Sidebar

Related Questions

In my Android application, when I rotate the device (slide out the keyboard) then
I have two threads in an Android application, one is the view thread, and
In Android, when layout out widgets, what's the difference between fill_parent ( match_parent in
I'm doing some Android development, and I much prefer Visual Studio, but I'll have
I'm building an Android app and I want to copy the text value of
I understand the Android OS is based on Linux. Does that mean the G1
Has anyone managed to use ItemizedOverlays in Android Beta 0.9? I can't get it
I've been working on the Android SDK platform, and it is a little unclear
Now that the G1 with Google's Android OS is now available (soon), will the
I am creating a matching game for Android, and when the user gets a

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.