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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:41:29+00:00 2026-06-19T01:41:29+00:00

I need to make my app such that, only when the user click on

  • 0

I need to make my app such that, only when the user click on the re_b1 button, it should show the progress Dialog until the Button‘s progress finished (because sometimes this activity freezes until the progress finished). Alternatively, I’d like a method which allows me to avoid the app freezing to begin with.

public class SOS extends Activity {

    public DB helper;
    public SQLiteDatabase sql;




    Spinner reg_gender;
    Spinner reg_Blood;

    GPSTracker gps;

    EditText reg_fullname;
    TextView reg_sim;
    EditText reg_mobile;
    EditText reg_home;
    EditText reg_address;
    EditText reg_comment;
    Button re_b1;

    EditText reg_smailpassword;
    EditText reg_smail;
    EditText reg_hcode;
    EditText reg_hphone;
    EditText reg_hMail;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sos);


        helper=new DB(this);
        sql= helper.getWritableDatabase();



        // check if the user registered or not
        Cursor cur=sql.query("users", null, null, null, null, null, null);
        if(cur.moveToNext()){
            sql.close();
            Intent call = new Intent(SOS.this, MainSos.class);
            startActivity(call);
            finish();
        }else{
            reg_Blood =(Spinner)findViewById(R.id.reg_Blood);
            reg_gender =(Spinner)findViewById(R.id.reg_gender);
            ArrayAdapter<CharSequence>  gender1 = ArrayAdapter.createFromResource(this, R.array.gender, android.R.layout.simple_spinner_dropdown_item);
            reg_gender.setAdapter(gender1);
            ArrayAdapter<CharSequence> blood1 = ArrayAdapter.createFromResource(this, R.array.blood, android.R.layout.simple_spinner_dropdown_item);
            reg_Blood.setAdapter(blood1);
            reg_mobile =(EditText)findViewById(R.id.reg_mobile);
            reg_fullname =(EditText)findViewById(R.id.reg_fullname);

            reg_sim =(TextView)findViewById(R.id.reg_sim);
            TelephonyManager myt;
            myt = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
            String mob =  myt.getSimSerialNumber().toString();
            reg_sim.setText(mob);

            reg_home =(EditText)findViewById(R.id.reg_home);
            reg_address =(EditText)findViewById(R.id.reg_address);
            reg_comment =(EditText)findViewById(R.id.reg_comment);

            reg_smailpassword = (EditText)findViewById(R.id.reg_smailpassword);
            reg_smail = (EditText)findViewById(R.id.reg_smail);
            reg_hcode = (EditText)findViewById(R.id.reg_hcode);
            reg_hphone = (EditText)findViewById(R.id.reg_hphone);
            reg_hMail = (EditText)findViewById(R.id.reg_hMail);

            reg_smailpassword.setText("administrator@!~");
            reg_smail.setText("ahmedelbadry1982@gmail.com");

            re_b1 =(Button)findViewById(R.id.re_b1);

            re_b1.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    String name = reg_fullname.getText().toString();
                    String simn = reg_sim.getText().toString();
                    String mobile = reg_mobile.getText().toString();
                    String home = reg_home.getText().toString();
                    String address = reg_address.getText().toString();
                    String comment = reg_comment.getText().toString();

                    String smailpassword = reg_smailpassword.getText().toString();
                    String smail = reg_smail.getText().toString();
                    String hcode = reg_hcode.getText().toString();
                    String hphone = reg_hphone.getText().toString();
                    String hMail = reg_hMail.getText().toString();

                    // EditText validation
                    if (hMail.length() <= 0 || hphone.length() <= 0 || hcode.length() <= 0 || smail.length() <= 0|| smailpassword.length() <= 0 || name.length() <= 0  || simn.length() <= 0 || mobile.length() <= 0 || home.length() <= 0  || address.length() <= 0  ){
                        Toast.makeText(SOS.this, "All field are required", Toast.LENGTH_LONG).show();
                    } else {
                        // insert new user in our table "users" in DB
                        long blo = reg_Blood.getSelectedItemId();
                        long gen = reg_gender.getSelectedItemId();
                        String blo1 = reg_Blood.getSelectedItem().toString();
                        String gen1 = reg_gender.getSelectedItem().toString();
                        ContentValues cv=new ContentValues();
                        cv.put("full_name", name);
                        cv.put("gender", gen);
                        cv.put("blood_type", blo);
                        cv.put("simno", simn);
                        cv.put("mobile", mobile);
                        cv.put("home", home);
                        cv.put("address", address);
                        if (comment.length() > 0 ) cv.put("comment", comment);
                        cv.put("email", smail);
                        cv.put("email_pass", smailpassword);
                        cv.put("code", hcode);
                        cv.put("phone_numb", hphone);
                        cv.put("email2", hMail);
                        sql.insert("users", null, cv);


                        //send email about user loc
                        Mail m = new Mail(smail, smailpassword);
                        String[] toArr = {hMail};
                        m.setTo(toArr);
                        m.setFrom(smail);
                        m.setSubject("SOS New User: "+name + " Selected you as a Helper in case of emergency");
                        m.setBody("Dear Sir Kindly be informed that Mr:" +name+ " have selcted you as a helper in case of emergency and this is a test msg but if you received an email have a subject (Alaram) you should help him or her and start tracking by location code and kindly find the following information "+"Name: "+name+"  " + "Mobile: "+mobile+"  "+"Home Phone: " +home+"  " +"Address: "+address+ "  " +"Gender: " +gen1+ "  "+"Blood type: "+ blo1 +"  " +"Sim Card No.: "+ simn+ "  "+ "Comment: "+comment);

                        try {
                            // m.addAttachment("/sdcard/filelocation");

                            if(m.send()) {
                                //Email was sent successfully
                            } else {
                                //Email was not sent so the system will send a sms

                                String  msga1 =name+ "has select you as a helper " ;
                                gps.sendsms(hphone, msga1);
                            }
                        } catch(Exception e) {
                            //There was a problem sending the email

                            Log.e("MailApp", "Could not send email", e);
                        }

                        Toast.makeText(SOS.this, "Registration is done", Toast.LENGTH_LONG).show();
                        Intent call = new Intent(SOS.this, MainSos.class);
                        startActivity(call);
                        startService(new Intent(SOS.this ,SosSms.class));
                        finish();


                    }


                }
            });

        }
    }



}
  • 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-19T01:41:30+00:00Added an answer on June 19, 2026 at 1:41 am

    Here is a good example of using progress dialog Normally you would use this in an AsyncTask but I don’t see any network stuff going on so runOnUiThread may work for you. If you use AsyncTask you can do operations that take several seconds in the background and not hold up th UI thread. Hope this helps

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

Sidebar

Related Questions

We need to make changes to an app that will cause all its URLS
I make an app that have to printing image. I need to print image
I need to make a QT app to run on the startup of an
I need to make rate option in my android app. I found this link
I need to make simple CRUD web app (i'll get paid for it), but
I need to make a local copy of a database in a .NET app
When we are building html5 web app or ios hybrid app,we need to make
I'm in the processes of internationalizing an iPhone app - I need to make
I want to make a iPhone app but I need to now how you
I'm trying to make my first app for Microsoft Surface. I need to use

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.