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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:40:58+00:00 2026-06-11T17:40:58+00:00

I am developing a simple Android app and am getting a ‘App stopped working’

  • 0

I am developing a simple Android app and am getting a ‘App stopped working’ error.

The error seems to happen when I exit my preOnExecute method but if I comment that out the app falls over on next code piece anyway.

Test: Open screen/activity, there are 5 pre filled textboxes and a button. If I click the button the code hits a class that opens a dialog in ‘OnPreExecute’ and it fails on execiting this method.

Its probably something to do with the background thread not liking whats happening on UI but i dont know.

Any idea how I can troubleshoot this?

See below for code

package android22.app.namespace;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.ConsoleMessage;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android22.voter.namespace.appSubmitAnswerActivity.GetQuestionDetails;
import android22.voter.namespace.appSubmitAnswerActivity.SaveAnswerDetails;

public class appCreateQuestionActivity extends Activity  {

    //controls

       EditText editTextTitle;
       EditText editTextQuestionString;
       EditText editTextA1;
       EditText editTextA2;
       EditText editTextA3;
       EditText editTextA4;
       EditText editTextA5;
       Button buttonSubmitQuestion;



       // Progress Dialog 
       private ProgressDialog qDialog; 

       // JSON parser class 
       JSONParser jsonParser = new JSONParser(); 

       // single question url 
       private static final String url_insert_question_details = "http://xxx.xxx.xxx.xxx/voter/Voter_Db_CreateNewQuestion.php"; 


       // JSON Node names
       private static final String TAG_SUCCESS = "success";
       private static final String TAG_QUESTION = "question";
       private static final String TAG_QID = "Qid";
       private static final String TAG_TITLE = "Title";
       private static final String TAG_QUESTIONSTRING = "QuestionString";
       private static final String TAG_A1 = "A1";
       private static final String TAG_A2 = "A2";
       private static final String TAG_A3 = "A3";
       private static final String TAG_A4 = "A4";
       private static final String TAG_A5 = "A5";


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

        // save button 
        buttonSubmitQuestion = (Button) findViewById(R.id.btnCreate); 
        /*Set Control Listeners */

        buttonSubmitQuestion.setOnClickListener(new View.OnClickListener() { 

           @Override
            public void onClick(View view) {           

                // starting background task to update question 
              new SaveQuestionDetails().execute();
            } 
        }); 



    }

    class SaveQuestionDetails extends AsyncTask<String, String, String> {

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

           /**
            * Saving question
            * */
           protected String doInBackground(String... args) {

               String Title = editTextTitle.getText().toString();
               String Question = editTextQuestionString.getText().toString();
               String A1 = editTextA1.getText().toString();
               String A2 = editTextA2.getText().toString();
               String A3 = editTextA3.getText().toString();
               String A4 = editTextA4.getText().toString();
               String A5 = editTextA5.getText().toString();


               // Building Parameters
               List<NameValuePair> params = new ArrayList<NameValuePair>();
               params.add(new BasicNameValuePair(TAG_QID, "1"));
               params.add(new BasicNameValuePair(TAG_TITLE, Title));
               params.add(new BasicNameValuePair(TAG_QUESTION, Question));
               params.add(new BasicNameValuePair(TAG_A1, A1));
               params.add(new BasicNameValuePair(TAG_A2, A2));
               params.add(new BasicNameValuePair(TAG_A3, A3));
               params.add(new BasicNameValuePair(TAG_A4, A4));
               params.add(new BasicNameValuePair(TAG_A5, A5));


               // sending modified data through http request
               // Notice that update question url accepts POST method
               JSONObject json = jsonParser.makeHttpRequest(url_insert_question_details,
                       "POST", params);

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

                   if (success == 1) {
                       // successfully updated
                       Intent i = getIntent();
                       // send result code 100 to notify about question update
                       setResult(100, i);
                       finish();
                   } else {
                       // failed to update question
                   }
               } 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 question updated
               qDialog.dismiss();
           }
       }
}

I get the following LogCat

09-20 16:03:15.703: D/gralloc_goldfish(658): Emulator without GPU emulation detected.
09-20 16:20:39.298: W/dalvikvm(658): threadid=12: thread exiting with uncaught exception (group=0x409961f8)
09-20 16:20:39.463: E/AndroidRuntime(658): FATAL EXCEPTION: AsyncTask #1
09-20 16:20:39.463: E/AndroidRuntime(658): java.lang.RuntimeException: An error occured while executing doInBackground()
09-20 16:20:39.463: E/AndroidRuntime(658):  at android.os.AsyncTask$3.done(AsyncTask.java:278)
09-20 16:20:39.463: E/AndroidRuntime(658):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
09-20 16:20:39.463: E/AndroidRuntime(658):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
09-20 16:20:39.463: E/AndroidRuntime(658):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
09-20 16:20:39.463: E/AndroidRuntime(658):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-20 16:20:39.463: E/AndroidRuntime(658):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
09-20 16:20:39.463: E/AndroidRuntime(658):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
09-20 16:20:39.463: E/AndroidRuntime(658):  at java.lang.Thread.run(Thread.java:856)
09-20 16:20:39.463: E/AndroidRuntime(658): Caused by: java.lang.NullPointerException
09-20 16:20:39.463: E/AndroidRuntime(658):  at android22.voter.namespace.AppCreateQuestionActivity$SaveQuestionDetails.doInBackground(VoterCreateQuestionActivity.java:109)
09-20 16:20:39.463: E/AndroidRuntime(658):  at android22.voter.namespace.AppCreateQuestionActivity$SaveQuestionDetails.doInBackground(VoterCreateQuestionActivity.java:1)
09-20 16:20:39.463: E/AndroidRuntime(658):  at android.os.AsyncTask$2.call(AsyncTask.java:264)
09-20 16:20:39.463: E/AndroidRuntime(658):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-20 16:20:39.463: E/AndroidRuntime(658):  ... 4 more
09-20 16:20:41.493: E/WindowManager(658): Activity android22.voter.namespace.AppCreateQuestionActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@416e3798 that was originally added here
09-20 16:20:41.493: E/WindowManager(658): android.view.WindowLeaked: Activity android22.voter.namespace.AppCreateQuestionActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@416e3798 that was originally added here
09-20 16:20:41.493: E/WindowManager(658):   at android.view.ViewRootImpl.<init>(ViewRootImpl.java:343)
09-20 16:20:41.493: E/WindowManager(658):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:245)
09-20 16:20:41.493: E/WindowManager(658):   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:193)
09-20 16:20:41.493: E/WindowManager(658):   at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:118)
09-20 16:20:41.493: E/WindowManager(658):   at android.view.Window$LocalWindowManager.addView(Window.java:537)
09-20 16:20:41.493: E/WindowManager(658):   at android.app.Dialog.show(Dialog.java:274)
09-20 16:20:41.493: E/WindowManager(658):   at android22.voter.namespace.AppCreateQuestionActivity$SaveQuestionDetails.onPreExecute(VoterCreateQuestionActivity.java:101)
09-20 16:20:41.493: E/WindowManager(658):   at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:561)
09-20 16:20:41.493: E/WindowManager(658):   at android.os.AsyncTask.execute(AsyncTask.java:511)
09-20 16:20:41.493: E/WindowManager(658):   at android22.voter.namespace.VoterCreateQuestionActivity$1.onClick(AppCreateQuestionActivity.java:81)
09-20 16:20:41.493: E/WindowManager(658):   at android.view.View.performClick(View.java:3480)
09-20 16:20:41.493: E/WindowManager(658):   at android.view.View$PerformClick.run(View.java:13983)
09-20 16:20:41.493: E/WindowManager(658):   at android.os.Handler.handleCallback(Handler.java:605)
09-20 16:20:41.493: E/WindowManager(658):   at android.os.Handler.dispatchMessage(Handler.java:92)
09-20 16:20:41.493: E/WindowManager(658):   at android.os.Looper.loop(Looper.java:137)
09-20 16:20:41.493: E/WindowManager(658):   at android.app.ActivityThread.main(ActivityThread.java:4340)
09-20 16:20:41.493: E/WindowManager(658):   at java.lang.reflect.Method.invokeNative(Native Method)
09-20 16:20:41.493: E/WindowManager(658):   at java.lang.reflect.Method.invoke(Method.java:511)
09-20 16:20:41.493: E/WindowManager(658):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-20 16:20:41.493: E/WindowManager(658):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-20 16:20:41.493: E/WindowManager(658):   at dalvik.system.NativeStart.main(Native Method)
  • 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-11T17:40:59+00:00Added an answer on June 11, 2026 at 5:40 pm

    The error is caused by line 109:

    String Title = editTextTitle.getText().toString();
    

    And it’s a NullPointerException. Most likely, it’s caused by the fact that class member variable editTextTitle is not initialized anywhere. You typically initialize those in your onCreate(), some time after setContentView(), by calling findViewById() with the relevant control ID.

    That said, questions of the type “here’s a large chunk of code, please debug for me” are frowned upon here at StackOverflow. You could’ve easily caught the error by placing a breakpoint inside the AsyncTask methods and stepping through each of them. That, or carefully reading the exception trace in the LogCat.

    EDIT: the following lines in the LogCat are relevant:

    09-20 16:20:39.463: E/AndroidRuntime(658): Caused by: java.lang.NullPointerException
    09-20 16:20:39.463: E/AndroidRuntime(658):  at android22.voter.namespace.AppCreateQuestionActivity$SaveQuestionDetails.doInBackground(VoterCreateQuestionActivity.java:109)
    

    The line number is right there. The exception was caught and rethrown a few times – that’s typical. But to find the ultimate cause, you look for your code in the stack trace.

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

Sidebar

Related Questions

I'm developing simple video recording app for Android 2.2+ and having trouble with getting
I am developing a simple sip-based voip app for android. I used this sample
I am using Android SDK 1.6 and developing some simple apps. It seems everytime
I'm new at android developing. I'm trying to make a simple drumset app, when
I'm developing a webapp+android app that has its own registration flow - simple authentication
I'm currently developing a simple multiplayer game app for Android and I need to
I'm developing a simple camera app which is based on the android developers tutorial
I am attempting to launch a simple test app on the Android emulator (developing
I am new to developing android apps. I am making an app where simple
I am new to Android, I am developing a simple and small app, which

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.