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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:06:25+00:00 2026-06-11T19:06:25+00:00

I’m very new in android and I’m developing an application that passes data from

  • 0

I’m very new in android and I’m developing an application that passes data from android to MySQL through PHP. I’m in registering users part now. I got some codes from searching but while i’m implementing it, I’m getting run-time errors. This is my code. The logcat is also at the bottom.

public class RegisterActivity extends Activity {

    // Progress Dialog
    private ProgressDialog pDialog;

    JSONParser jsonParser = new JSONParser();
    EditText registerName;
    EditText registerRollno;
    EditText inputDesc;

    // url to create new product
    private static String url_create_voter = "http://10.0.2.2/evoting/create_voter.php";

    // JSON Node names
    private static final String TAG_SUCCESS = "success";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register1);

        // Edit Text
        EditText registerName = (EditText) findViewById(R.id.registerName);
        EditText registerRollno = (EditText) findViewById(R.id.registerRollno);
       // inputDesc = (EditText) findViewById(R.id.inputDesc);

        // Create button
        Button btnSubmit = (Button) findViewById(R.id.btnSubmit);

        // button click event
        btnSubmit.setOnClickListener(new View.OnClickListener() {


            public void onClick(View view) {
                // creating new product in background thread
                new CreateNewVoter().execute();
            }
        });
    }

    /**
     * Background Async Task to Create new product
     * */
    class CreateNewVoter extends AsyncTask<String, String, String> {

        /**
         * Before starting background thread Show Progress Dialog
         * */
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(RegisterActivity.this);
            pDialog.setMessage("Creating Voter..");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }

        /**
         * Creating product
         * */
        protected String doInBackground(String... args) {
            String name = registerName.getText().toString();
            String rollno = registerRollno.getText().toString();
            //String description = inputDesc.getText().toString();

            // Building Parameters
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("name", name));
            params.add(new BasicNameValuePair("rollno", rollno));
           // params.add(new BasicNameValuePair("description", description));

            // getting JSON Object
            // Note that create product url accepts POST method
            JSONObject json = jsonParser.makeHttpRequest(url_create_voter,
                    "POST", params);

            // check log cat fro response
            Log.d("Create Response", json.toString());

            // check for success tag




            try {
                int success = json.getInt(TAG_SUCCESS);

                if (success == 1) {
                    // successfully created product
                    Intent i = new Intent(getApplicationContext(), CreateVoterSuccess.class);
                    startActivity(i);

                    // closing this screen
                    finish();
                } else {
                    Intent i = new Intent(getApplicationContext(), CreateVoterFail.class);
                    startActivity(i);
                    // failed to create product
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }





            return null;
        }

        /**
         * After completing background task Dismiss the progress dialog
         * **/
        protected void onPostExecute(String file_url) {
            // dismiss the dialog once done
            pDialog.dismiss();
        }

    }
}

This is the logcat:

09-22 05:47:52.343: W/KeyCharacterMap(279): No keyboard for id 0
09-22 05:47:52.343: W/KeyCharacterMap(279): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-22 05:47:54.403: W/dalvikvm(279): threadid=7: thread exiting with uncaught exception (group=0x4001d800)
09-22 05:47:54.414: E/AndroidRuntime(279): FATAL EXCEPTION: AsyncTask #1
09-22 05:47:54.414: E/AndroidRuntime(279): java.lang.RuntimeException: An error occured while executing doInBackground()
09-22 05:47:54.414: E/AndroidRuntime(279):  at android.os.AsyncTask$3.done(AsyncTask.java:200)
09-22 05:47:54.414: E/AndroidRuntime(279):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
09-22 05:47:54.414: E/AndroidRuntime(279):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
09-22 05:47:54.414: E/AndroidRuntime(279):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
09-22 05:47:54.414: E/AndroidRuntime(279):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-22 05:47:54.414: E/AndroidRuntime(279):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
09-22 05:47:54.414: E/AndroidRuntime(279):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
09-22 05:47:54.414: E/AndroidRuntime(279):  at java.lang.Thread.run(Thread.java:1096)
09-22 05:47:54.414: E/AndroidRuntime(279): Caused by: java.lang.NullPointerException
09-22 05:47:54.414: E/AndroidRuntime(279):  at com.example.evoting.RegisterActivity$CreateNewVoter.doInBackground(RegisterActivity.java:83)
09-22 05:47:54.414: E/AndroidRuntime(279):  at com.example.evoting.RegisterActivity$CreateNewVoter.doInBackground(RegisterActivity.java:1)
09-22 05:47:54.414: E/AndroidRuntime(279):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
09-22 05:47:54.414: E/AndroidRuntime(279):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-22 05:47:54.414: E/AndroidRuntime(279):  ... 4 more
09-22 05:47:55.313: E/WindowManager(279): Activity com.example.evoting.RegisterActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f28db0 that was originally added here
09-22 05:47:55.313: E/WindowManager(279): android.view.WindowLeaked: Activity com.example.evoting.RegisterActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f28db0 that was originally added here
09-22 05:47:55.313: E/WindowManager(279):   at android.view.ViewRoot.<init>(ViewRoot.java:247)
09-22 05:47:55.313: E/WindowManager(279):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
09-22 05:47:55.313: E/WindowManager(279):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
09-22 05:47:55.313: E/WindowManager(279):   at android.view.Window$LocalWindowManager.addView(Window.java:424)
09-22 05:47:55.313: E/WindowManager(279):   at android.app.Dialog.show(Dialog.java:241)
09-22 05:47:55.313: E/WindowManager(279):   at com.example.evoting.RegisterActivity$CreateNewVoter.onPreExecute(RegisterActivity.java:76)
09-22 05:47:55.313: E/WindowManager(279):   at android.os.AsyncTask.execute(AsyncTask.java:391)
09-22 05:47:55.313: E/WindowManager(279):   at com.example.evoting.RegisterActivity$1.onClick(RegisterActivity.java:56)
09-22 05:47:55.313: E/WindowManager(279):   at android.view.View.performClick(View.java:2408)
09-22 05:47:55.313: E/WindowManager(279):   at android.view.View$PerformClick.run(View.java:8816)
09-22 05:47:55.313: E/WindowManager(279):   at android.os.Handler.handleCallback(Handler.java:587)
09-22 05:47:55.313: E/WindowManager(279):   at android.os.Handler.dispatchMessage(Handler.java:92)
09-22 05:47:55.313: E/WindowManager(279):   at android.os.Looper.loop(Looper.java:123)
09-22 05:47:55.313: E/WindowManager(279):   at android.app.ActivityThread.main(ActivityThread.java:4627)
09-22 05:47:55.313: E/WindowManager(279):   at java.lang.reflect.Method.invokeNative(Native Method)
09-22 05:47:55.313: E/WindowManager(279):   at java.lang.reflect.Method.invoke(Method.java:521)
09-22 05:47:55.313: E/WindowManager(279):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-22 05:47:55.313: E/WindowManager(279):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-22 05:47:55.313: E/WindowManager(279):   at dalvik.system.NativeStart.main(Native Method)
09-22 05:47:57.133: I/Process(279): Sending signal. PID: 279 SIG: 9
09-22 05:56:34.157: W/KeyCharacterMap(291): No keyboard for id 0
09-22 05:56:34.157: W/KeyCharacterMap(291): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-22 05:56:36.553: W/dalvikvm(291): threadid=7: thread exiting with uncaught exception (group=0x4001d800)
09-22 05:56:36.563: E/AndroidRuntime(291): FATAL EXCEPTION: AsyncTask #1
09-22 05:56:36.563: E/AndroidRuntime(291): java.lang.RuntimeException: An error occured while executing doInBackground()
09-22 05:56:36.563: E/AndroidRuntime(291):  at android.os.AsyncTask$3.done(AsyncTask.java:200)
09-22 05:56:36.563: E/AndroidRuntime(291):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
09-22 05:56:36.563: E/AndroidRuntime(291):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
09-22 05:56:36.563: E/AndroidRuntime(291):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
09-22 05:56:36.563: E/AndroidRuntime(291):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-22 05:56:36.563: E/AndroidRuntime(291):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
09-22 05:56:36.563: E/AndroidRuntime(291):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
09-22 05:56:36.563: E/AndroidRuntime(291):  at java.lang.Thread.run(Thread.java:1096)
09-22 05:56:36.563: E/AndroidRuntime(291): Caused by: java.lang.NullPointerException
09-22 05:56:36.563: E/AndroidRuntime(291):  at com.example.evoting.RegisterActivity$CreateNewVoter.doInBackground(RegisterActivity.java:83)
09-22 05:56:36.563: E/AndroidRuntime(291):  at com.example.evoting.RegisterActivity$CreateNewVoter.doInBackground(RegisterActivity.java:1)
09-22 05:56:36.563: E/AndroidRuntime(291):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
09-22 05:56:36.563: E/AndroidRuntime(291):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-22 05:56:36.563: E/AndroidRuntime(291):  ... 4 more
09-22 05:56:37.203: E/WindowManager(291): Activity com.example.evoting.RegisterActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f21560 that was originally added here
09-22 05:56:37.203: E/WindowManager(291): android.view.WindowLeaked: Activity com.example.evoting.RegisterActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f21560 that was originally added here
09-22 05:56:37.203: E/WindowManager(291):   at android.view.ViewRoot.<init>(ViewRoot.java:247)
09-22 05:56:37.203: E/WindowManager(291):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
09-22 05:56:37.203: E/WindowManager(291):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
09-22 05:56:37.203: E/WindowManager(291):   at android.view.Window$LocalWindowManager.addView(Window.java:424)
09-22 05:56:37.203: E/WindowManager(291):   at android.app.Dialog.show(Dialog.java:241)
09-22 05:56:37.203: E/WindowManager(291):   at com.example.evoting.RegisterActivity$CreateNewVoter.onPreExecute(RegisterActivity.java:76)
09-22 05:56:37.203: E/WindowManager(291):   at android.os.AsyncTask.execute(AsyncTask.java:391)
09-22 05:56:37.203: E/WindowManager(291):   at com.example.evoting.RegisterActivity$1.onClick(RegisterActivity.java:56)
09-22 05:56:37.203: E/WindowManager(291):   at android.view.View.performClick(View.java:2408)
09-22 05:56:37.203: E/WindowManager(291):   at android.view.View$PerformClick.run(View.java:8816)
09-22 05:56:37.203: E/WindowManager(291):   at android.os.Handler.handleCallback(Handler.java:587)
09-22 05:56:37.203: E/WindowManager(291):   at android.os.Handler.dispatchMessage(Handler.java:92)
09-22 05:56:37.203: E/WindowManager(291):   at android.os.Looper.loop(Looper.java:123)
09-22 05:56:37.203: E/WindowManager(291):   at android.app.ActivityThread.main(ActivityThread.java:4627)
09-22 05:56:37.203: E/WindowManager(291):   at java.lang.reflect.Method.invokeNative(Native Method)
09-22 05:56:37.203: E/WindowManager(291):   at java.lang.reflect.Method.invoke(Method.java:521)
09-22 05:56:37.203: E/WindowManager(291):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-22 05:56:37.203: E/WindowManager(291):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-22 05:56:37.203: E/WindowManager(291):   at dalvik.system.NativeStart.main(Native Method)
09-22 05:56:41.412: I/Process(291): Sending signal. PID: 291 SIG: 9
  • 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-11T19:06:26+00:00Added an answer on June 11, 2026 at 7:06 pm

    Local variables shadow object variables:

        EditText registerName;
        EditText registerRollno;
    
    // [...]
     public void onCreate(Bundle savedInstanceState) {
    
     [...]
            EditText registerName = (EditText) findViewById(R.id.registerName);
            EditText registerRollno = (EditText) findViewById(R.id.registerRollno);
    

    Creating local variables with the same name as object variables is not an error by default, but it looks like a mistake here.

    This way the object variables will still be null, hence the NPE.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.