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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:56:54+00:00 2026-06-17T08:56:54+00:00

I am developing a simple application which sends the pseudo random string to the

  • 0

I am developing a simple application which sends the pseudo random string to the server database. Here I am using AsyncTask for sending string to server and ProgressDialog in foreground. The problem is the progress dialog is not stopping and I don’t gt any string at server. Maybe there is some problem in the code of sending srcetring. I am new to Android and learn from sources available on the Internet. Here is the code which I use.

public class MainActivity extends Activity {

    Button btn;
    TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv = (TextView)findViewById(R.id.textView2);
        btn = (Button)findViewById(R.id.button1);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    public void getThis(View v) {
        String str = "35" +
            Build.BOARD.length()%10+ Build.BRAND.length()%10 + 
            Build.CPU_ABI.length()%10 + Build.DEVICE.length()%10 + 
            Build.DISPLAY.length()%10 + Build.HOST.length()%10 + 
            Build.ID.length()%10 + Build.MANUFACTURER.length()%10 + 
            Build.MODEL.length()%10 + Build.PRODUCT.length()%10 + 
            Build.TAGS.length()%10 + Build.TYPE.length()%10 + 
            Build.USER.length()%10 ; 
        tv.setText(str);
        UploadUniqueID uni=new UploadUniqueID(this,str);
        uni.execute(str);
    }

    class UploadUniqueID extends AsyncTask<String, Integer, String> {

        Context context;
        MainActivity ma;
        ProgressDialog dialog;
        String id;
        public UploadUniqueID(MainActivity activity,String str) {
            ma = activity;
            context = activity;
            dialog = new ProgressDialog(context);
            id = str;
        }

        protected void onPreExecute() {
            this.dialog.setMessage("Progress start");
            this.dialog.setCancelable(true); 
            this.dialog.show();
        }

        @Override
        protected String doInBackground(String... params) {
            // perform long running operation operation
            String id=params[0];
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://10.0.2.2/UniqueIdApp/myPHP.php");

            try {
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
                nameValuePairs.add(new BasicNameValuePair("android",id));     
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                httpclient.execute(httppost);          
            } catch (Exception e) {
                Log.i("HTTP Failed", e.toString());
            }            

            return null;
        }

        protected void onProgressUpdate(Integer...integers) {

        }

        protected void onPostExecute(String...strings) {
            tv.setText("Sent"); 
            if (dialog.isShowing()) {
                dialog.dismiss();
            }
        }
    }
}
  • 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-17T08:56:55+00:00Added an answer on June 17, 2026 at 8:56 am

    You can also create and initialize the dialog in your UploadUniqueID AsyncTask class by doing:

    private final ProgressDialog dialog = new ProgressDialog(MainActivity.this);
    

    and just dismiss it in your onPostExecute(...) method as you are currently doing. Also, add the @Override annotation to your onPreExecute() method.

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

Sidebar

Related Questions

I am developing a simple application using win forms C# in which simple text
I am developing a simple application for Android in which I am using a
I am developing a simple application which has to send an SMS message from
I'm developing a simple application to manage the operational part of a business using
I am developing a simple pyramid application where I am using JQuery to do
I am developing a simple WPF Application that requires a database. My question is,
I'm currently developing a simple iPhone application using a UITabBar and table views for
I am developing an application which connects to the server. By now the login
I am developing a very simple application which accesses a written url. So i
We are developing a simple web application in JSF in which there is 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.