Android Application crashes suddenly -- I don't what mistake I have made
<p>Android application(periodically gets responds from server) automatically crashes after running some time i have enclosed the log kindly help me..</p>

<pre>
W/dalvikvm(2718): Invalid indirect reference 0x17f0d00 in decodeIndirectRef
E/dalvikvm(2718): VM aborting
A/libc(2718): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)

</pre>

<p><strong>here is my code</strong></p>

<p><strong>question.java</strong></p>

<p>public class QuestionPaper extends Activity {</p>

<pre><code>final static String DEBUG_TAG = "MakePhotoActivity";
boolean answerChangeFlag = false;
DatabaseHandler db = new DatabaseHandler(this);
QABackEnd examQABackEnd = new QABackEnd(this);

int QNo=0;
int TotalQuestion = 0;
int MAX_OPTION=4;
int pn = 0; //Redundant variable 
Button previousButton;//changed due to enable and disable next button on
Button nextButton;
RadioButton[] RadioButtonChoice = new RadioButton[MAX_OPTION];
CheckBox[] CheckButtonChoice = new CheckBox[MAX_OPTION];
EditText editTextBlank;
String Question;
String encQues=null;
String QuestionType;
String Answer;  
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.questionpaper);
    previousButton = (Button)findViewById(R.id.previous);
    nextButton = (Button)findViewById(R.id.next);       
    /**** Get data from ExamInfo *********/
    Intent intent = getIntent();
    String respQuestion=intent.getExtras().getString("question");
    Log.d("@@@@@@@@@@",respQuestion);
    QNo = intent.getExtras().getInt("QNo");
    int totaltime = intent.getExtras().getInt("totaltime");
    TotalQuestion = intent.getExtras().getInt("totalquestions");

    /**** Insert first question in local DB ********/
    db.insertQuestionToQA(QNo, respQuestion);
    startStopExamTime(totaltime);
    constructQuestionOnScreen(QNo, respQuestion);
    }
@Override
protected void onStart() {// The activity is about to become visible.
    super.onStart();

}

@Override
protected void onResume() {// The activity has become visible (it is now "resumed").
    super.onResume();       
}
@Override
protected void onPause() {// Another activity is taking focus (this activity is about to be "paused").
    super.onPause(); 
}
@Override
protected void onStop() {// The activity is no longer visible (it is now "stopped")

    super.onStop();

}
@Override
protected void onDestroy() { // The activity is about to be destroyed.
    super.onDestroy();
    try{
        String finish ="LogOut";
        new ExamURL();
        String logoutURL = ExamURL.getLogoutURL();
        ArrayList&lt;NameValuePair&gt; questionParameters = new ArrayList&lt;NameValuePair&gt;();
        questionParameters.add(new BasicNameValuePair("rollNumber",StudentInformation.getRollNumber()));
        questionParameters.add(new BasicNameValuePair("status", finish));
        WebService wsFirstQuestion = new WebService(logoutURL,questionParameters,new WebService.OnPostExecuteListener() {

            public void onPostExecute(String wsResponse) {
                QuestionPaper.this.finish();    
            }
        }); wsFirstQuestion.execute();
        }catch(Exception e)
        {
            /**write the error in to log file exit 
            *from the application
            */
            Toast.makeText(getApplicationContext(), "Server Response Failure", Toast.LENGTH_SHORT).show();
            QuestionPaper.this.finish();
        } 
}    
public void startStopExamTime(int waitTime)
{
    String time = Integer.toString(waitTime);
    Log.d("******WAITING TIME IS***",time);//used for testing
     Handler examTimeHandler = new Handler();
      Runnable examRunMethod = new Runnable()
      {
        public void run() {     
               Toast.makeText(getApplicationContext(), "End of Time", Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(QuestionPaper.this, ExamManagement.class);
                QuestionPaper.this.finish();
                startActivity(intent);      
        }
      };
      ExamTimer examTimer = new ExamTimer(examTimeHandler,examRunMethod,waitTime); 
      examTimer.start();
}
private JSONObject questionDecryption(String encryptJSONQuestion)
{
    //Decrypt the json
    String strJsonQuestion = null;
    try
    {
        strJsonQuestion = AESencryp.decrypt(encryptJSONQuestion);
        JSONObject jsonQuestion = new JSONObject(strJsonQuestion);
        return jsonQuestion;
    }
    catch (Exception e)
    {


        Log.d("Error while Decryption :", e.toString());
        return null;
    }

}

private void constructQuestionOnScreen (int qNo,String encryptJSONQuestion)
{
    QNo = qNo;
    Answer = "0000";
     try
        {
            JSONObject jsonQuestion1 = new JSONObject();

            jsonQuestion1 = questionDecryption (encryptJSONQuestion);

            JSONObject jsonQuestion = jsonQuestion1.getJSONObject("0");

            QuestionType = (String) jsonQuestion.get("type");
            Question = (String) jsonQuestion.get("question");
            Log.d("Question: ",  Question); 

        final String mimeType = "text/html";
        final String encoding = "UTF-8";

        WebView webView = (WebView) findViewById(R.id.webView1);
        webView.clearHistory();
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        webView.setScrollbarFadingEnabled(false);
        webView.loadDataWithBaseURL("", Question, mimeType, encoding, "");

        if(QuestionType.equals("blank"))
        {
            constructOneWordOnScreen(qNo);
        }
        else
        {

            String optiona, optionb, optionc, optiond;
            optiona = (String) jsonQuestion.get("option1");
            optionb = (String) jsonQuestion.get("option2");
            optionc = (String) jsonQuestion.get("option3");
            optiond = (String) jsonQuestion.get("option4");
    Log.d("option1",optiona);
    Log.d("option2",optionb);
    Log.d("option3",optionc);
    Log.d("option4",optiond);

            constructQuestionChoiceOnScreen(optiona,optionb,optionc,optiond);

        }
    }
    catch (JSONException e)
    {
        //Check encrypted question==null if yes againg shld ged encrypteted json question 
        /**write the error in to log file*/
        Log.d("Error in json :", e.toString());

    }


    if (QNo &lt;= 1)
        previousButton.setEnabled(false);
    else
        previousButton.setEnabled(true);

    if (QNo &gt;= TotalQuestion)
    {
        nextButton.setEnabled(true);
        nextButton.setText("Finish");
    }
    else
    {
        nextButton.setEnabled(true);//after clicking next button should be disabled till this line then this line is enabling
        nextButton.setText("Next");
    }

 }


private boolean checkIFAnswered(int qno)
{
    String dbAnswer = db.displayAnswer(qno);

    if(dbAnswer == null)
    {
        return false;
    }
    else if (dbAnswer.equals("null"))
    {
        return false;
    }
    else 
    {
    try {
        String convertedAnswer;
        String decryptedAnswer = AESencryp.decrypt(dbAnswer);
        JSONObject jsonAnswer = new JSONObject(decryptedAnswer);

        if (QuestionType.equals("blank"))
        {
            convertedAnswer = ((String) jsonAnswer.get("oneword"));
        }
        else
        {
            convertedAnswer="0000";
            Log.d("****In else****","***Check if answered****");
            Log.d("-------Answer is",Answer);
            StringBuilder strAnswer = new StringBuilder(convertedAnswer);
            //ans.append("0000");

            if (jsonAnswer.getInt("optiona") == 1)
                strAnswer.setCharAt(0, '1');
            if (jsonAnswer.getInt("optionb") == 1)
                strAnswer.setCharAt(1, '1');
            if (jsonAnswer.getInt("optionc") == 1)
                strAnswer.setCharAt(2, '1');
            if (jsonAnswer.getInt("optiond") == 1)
                strAnswer.setCharAt(3, '1');
            convertedAnswer = strAnswer.toString();
            Log.d("****Converted answer is",convertedAnswer);
        }
        if (convertedAnswer.equals("0000")) {
            Log.d("check if answered function *****Answer is 0000","*****Answer is 0000");
            return false;
        }
        else if (convertedAnswer.equals("")) {
            return false;
        }
        else {
            return true;
        }
    }
    catch (Exception e){
        /**write the error in to log file*/
        /**Check answer is present in server else display 0000**/
        /**probably here error wont occur**/
        return false;
    }


    }

}

private String convertEncryptedAnswerToString(int qno)
{
    StringBuilder strAnswer;
        try
            {
                String dbAnswer = db.displayAnswer(qno);

                //if(dbAnswer!=null) This is not working and need to be analysed
                /*** The below statement expects that the question record is already inserted in the DB ******/
                /***** Otherwise null pointer exception occurs *****/ 
                if (dbAnswer == null)
                    {
                    Log.d(";;;In Convert Encrypted Answer To String dbAnswer==null;;;","In Convert Encrypted Answer To String dbAnswer==null");
                        if (QuestionType.equals("blank"))
                        {
                            Answer = "";
                        }
                        else
                        {
                            Answer = "0000";
                        }
                    }
                else if (!dbAnswer.equals("null"))
                {

                    String decryptedAnswer = AESencryp.decrypt(dbAnswer);
                    JSONObject jsonAnswer = new JSONObject(decryptedAnswer);
                    if (QuestionType.equals("blank"))
                    {
                        Answer = ((String) jsonAnswer.get("oneword"));
                    }
                    else
                    {
                        strAnswer = new StringBuilder(Answer);


                        if (jsonAnswer.getInt("optiona") == 1)
                            strAnswer.setCharAt(0, '1');
                        if (jsonAnswer.getInt("optionb") == 1)
                            strAnswer.setCharAt(1, '1');
                        if (jsonAnswer.getInt("optionc") == 1)
                            strAnswer.setCharAt(2, '1');
                        if (jsonAnswer.getInt("optiond") == 1)
                            strAnswer.setCharAt(3, '1');
                        Answer = strAnswer.toString();
                    }
                }
                else
                {

                    if (QuestionType.equals("blank"))
                    {
                        Answer = "";
                    }
                    else
                    {
                        Answer = "0000";
                    }
                }
                return Answer;
 }
        catch (Exception e)
        {
            Log.d("Error in getAnswerInStringBuilder :", e.toString());
            /**write the error in to log file*/
            /**Check answer is present in server else display 0000**/
            return null;
        }
}
    private void constructOneWordOnScreen(int qNo)
    {
        LinearLayout layconstructQuestionOnScreenout = (LinearLayout)findViewById(R.id.optiona);
        layconstructQuestionOnScreenout.setOrientation(LinearLayout.HORIZONTAL);
        editTextBlank = new EditText(this);
        Answer = convertEncryptedAnswerToString(qNo);
        if(Answer.equals(""))
            editTextBlank.setHint("ENTER YOUR ANSWER");
        else
            editTextBlank.setText(Answer);

        layconstructQuestionOnScreenout.addView(editTextBlank);

    }

    public void constructQuestionChoiceOnScreen(String optiona, String optionb, String optionc, String optiond)
    {

        Answer = convertEncryptedAnswerToString(QNo);
        Log.d("*****In construct question choice on screen******",Answer);
        LinearLayout[] linearLayout = new LinearLayout[MAX_OPTION];
        WebView webView[] = new WebView[4];



        for (int i = 0 ; i &lt; MAX_OPTION ; i++)
        {
            int linearLayoutID = 0;
            String optionString = null;
            boolean checkValue= false;


            switch (i)
            {
                case 0 :
                    linearLayoutID = R.id.optiona;
                    optionString = optiona;
                    break;
                case 1 :
                    linearLayoutID = R.id.optionb;
                    optionString = optionb;
                    break;
                case 2 :
                    linearLayoutID = R.id.optionc;
                    optionString = optionc;
                    break;
                case 3 :
                    linearLayoutID = R.id.optiond;
                    optionString = optiond;
                    break;

            }
            if (Answer.charAt(i) == '1')
                checkValue = true;

            linearLayout[i] = (LinearLayout) findViewById(linearLayoutID);
            linearLayout[i].setOrientation(LinearLayout.HORIZONTAL);

            if(QuestionType.contentEquals("single"))
            {
                RadioButtonChoice[i] = new RadioButton(this);
                RadioButtonChoice[i].setId(i);

                linearLayout[i].addView(RadioButtonChoice[i]);

                RadioButtonChoice[i].setChecked(checkValue);

                Log.i("value of ","Radio"+Integer.toString(i)+" "+Answer.toString());


                RadioButtonChoice[i].setOnCheckedChangeListener(new OnCheckedChangeListener() {

                        public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
                        answerChangeFlag = true;
                        Log.i("Onclick listener called", Integer.toString(arg0.getId()));
                        if(arg0.isChecked())
                        {
                            StringBuilder strAnswer = new StringBuilder(Answer);
                            for (int j = 0; j &lt; 4;j++)
                            {
                                if(j != arg0.getId())
                                {
                                    RadioButtonChoice[j].setChecked(false);
                                    Toast.makeText(getApplicationContext(), "radio"+Integer.toString(arg0.getId())+" is clicked", Toast.LENGTH_SHORT).show();
                                    strAnswer.setCharAt(j,'0');
                                }
                                else
                                    strAnswer.setCharAt(j,'1');
                            }
                            Answer = strAnswer.toString();
                        }

                        Log.i("RadioChangeAction for","i "+ Answer);
                    }
                });
            }
            else
            {
                CheckButtonChoice[i]=new CheckBox(this);
                CheckButtonChoice[i].setId(i);
                linearLayout[i].addView(CheckButtonChoice[i]);
                CheckButtonChoice[i].setChecked(checkValue);
                CheckButtonChoice[i].setOnCheckedChangeListener(new OnCheckedChangeListener() {
                      public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
                          answerChangeFlag = true;
                          StringBuilder strAnswer = new StringBuilder(Answer);
                          if (arg0.isChecked())
                            strAnswer.setCharAt(arg0.getId(), '1');
                          else
                            strAnswer.setCharAt(arg0.getId(), '0');

                         Answer = strAnswer.toString();
                        Log.i("Answer is ", Answer);         
                    }
                   });

            }

            final String mimeType = "text/html";
            final String encoding = "UTF-8";
            webView[i]=new WebView(this);
            webView[i].getSettings().setLoadWithOverviewMode(true);
            webView[i].clearHistory();

            webView[i].setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
            webView[i].setScrollbarFadingEnabled(false);

            webView[i].loadDataWithBaseURL("", optionString, mimeType, encoding, "");
            linearLayout[i].addView(webView[i]);


        }//For Loop End

    }

    private String convertStringToEncryptedAnswer()
    {
        try
        {
            JSONObject obj = new JSONObject();

            if (QuestionType.equals("blank"))
            {
                obj.put("oneword", Answer);
            }
            else
            {
                 if(Answer.charAt(0) == '1')
                     obj.put("optiona", 1);
                 else
                     obj.put("optiona", 0);

                 if(Answer.charAt(1) == '1')
                     obj.put("optionb", 1);
                 else
                     obj.put("optionb", 0);

                 if(Answer.charAt(2) == '1')
                     obj.put("optionc", 1);
                 else
                     obj.put("optionc", 0);

                 if(Answer.charAt(3) == '1')
                     obj.put("optiond", 1);
                 else
                     obj.put("optiond", 0);

            }
            String answ = obj.toString();
            String JSONansw = AESencryp.encrypt(answ);
            return JSONansw;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            Log.d("Error : ",  e.toString());
            return e.toString();
        }
    }

    private void clearAllLayouts()
    {
        LinearLayout layout = (LinearLayout)findViewById(R.id.optiona);
        LinearLayout layout1 = (LinearLayout)findViewById(R.id.optionb);
        LinearLayout layout2 = (LinearLayout)findViewById(R.id.optionc);
        LinearLayout layout3 = (LinearLayout)findViewById(R.id.optiond);
        layout.removeAllViewsInLayout();
        layout1.removeAllViewsInLayout();
        layout2.removeAllViewsInLayout();
        layout3.removeAllViewsInLayout();
    }

    public void clearAllAnswerOnScreen()
    {
        int i = 0;
        if(QuestionType.equals("single"))
        {
            for (i = 0; i &lt; MAX_OPTION; i++)
                RadioButtonChoice[i].setChecked(false);

        }
        if(QuestionType.equals("multi"))
        {
            for (i = 0; i &lt; MAX_OPTION; i++)
                CheckButtonChoice[i].setChecked(false);
        }
        if(QuestionType.equals("blank"))
        {
            editTextBlank.clearComposingText();
        }
    }


    public void OnClickClear(View view)
    {
        Answer = "0000";
        answerChangeFlag = true;
        clearAllAnswerOnScreen();
    }

    public void OnClickPrevious(View view)
    {  
        previousButton.setEnabled(false);//disabling after clicking till finished cunstructQuestionsOnScreen
        int qNo = 0;
        pn=1;
        qNo = QNo-1;
        clearAllAnswerOnScreen();
        clearAllLayouts();

        callQABackEnd(qNo);

    }

    public void onClickNext(View view)
    {

        nextButton.setEnabled(false);//disabling after clicking till finished cunstructQuestionsOnScreen
        int qNo = 0;
        //pn=2;
        if(QNo&gt;=TotalQuestion)
        {
            qNo=QNo;
            clickedFinish();
        }
        else{
        qNo = QNo+1;
        clearAllAnswerOnScreen();
        clearAllLayouts();
        }

        callQABackEnd(qNo);

    }

    public void clickedFinish()
    {


        final Context context = this;
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
            alertDialogBuilder.setTitle("Exam Complete");
            alertDialogBuilder
            .setMessage("Do You Want To Finish Exam??")
            .setCancelable(false)
            .setPositiveButton("Yes",new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog,int id) {
                    // if this button is clicked, close
                    // current activity
                    try{
                    String finish ="LogOut";
                    new ExamURL();
                    String logoutURL = ExamURL.getLogoutURL();
                    ArrayList&lt;NameValuePair&gt; questionParameters = new ArrayList&lt;NameValuePair&gt;();
                    questionParameters.add(new BasicNameValuePair("rollNumber",StudentInformation.getRollNumber()));
                    questionParameters.add(new BasicNameValuePair("status", finish));
                    WebService wsFirstQuestion = new WebService(logoutURL,questionParameters,new WebService.OnPostExecuteListener() {

                        public void onPostExecute(String wsResponse) {

                            QuestionPaper.this.finish();
                            startActivity(new Intent(QuestionPaper.this, ExamManagement.class));

                        }
                    }); wsFirstQuestion.execute();
                    }catch(Exception e)
                    {
                         Log.d("Error : ",  e.toString());  
                    }


                }
              })
            .setNegativeButton("No",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {

                    dialog.cancel();
                }
            });
            AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();

        }    




    public void onClickViewer(View view)
    {
        //try{
                boolean answeredFlag;
                 final AlertDialog.Builder singlechoicedialog = new AlertDialog.Builder(this);
                 List&lt;String&gt; questions = new ArrayList&lt;String&gt;();

                 for(int j=1;j&lt;=TotalQuestion;j++)
                 {

                     answeredFlag = checkIFAnswered(j);
                     if(answeredFlag == true)
                     {

                         String answ = "true"+j;
                         Log.d("Answered flag is",answ);
                         questions.add("question"+j+":     Answered");

                     }
                     else{
                         String answ = "false"+j; 
                         Log.d("Answered flag is",answ);
                         questions.add("question"+j+":    Not Answered");

                     }

                 }
                 final CharSequence[] charSequenceItems = questions.toArray(new CharSequence[questions.size()]);

                 singlechoicedialog.setTitle("Randon Question Viewer");
                 singlechoicedialog.setSingleChoiceItems(charSequenceItems, -1,
                 new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int item) {

                  String value = charSequenceItems[item].toString();

                  clearAllAnswerOnScreen();
                  clearAllLayouts();
                  pn=1;
                  Log.d("******calling QABackEndFromViewer","******calling QABackEndFromViewer");
                  callQABackEnd(item+1);


                  dialog.cancel();
                  }
                 });
                 AlertDialog alert_dialog = singlechoicedialog.create();
                 alert_dialog.show();


                 String qnoo = Integer.toString(QNo-1);
                 Log.d("QuestionNumber",qnoo);
                 alert_dialog.getListView().setItemChecked(QNo-1, true);

    }


    public void callQABackEnd(final int newQNo)
    {
        Log.i("Final Answer ","*****  "+Answer);
        String encryptAnswer = convertStringToEncryptedAnswer();
        encQues = examQABackEnd.backEndTask(QNo, encryptAnswer, newQNo);

          try{
             if(answerChangeFlag==true){

                answerChangeFlag=false;
                ArrayList&lt;NameValuePair&gt; answerParameters = new ArrayList&lt;NameValuePair&gt;();
                answerParameters.add(new BasicNameValuePair("rollNumber", StudentInformation.getRollNumber()));
                answerParameters.add(new BasicNameValuePair("reqQNo",Integer.toString(QNo)));
                answerParameters.add(new BasicNameValuePair("answer",encryptAnswer));
                WebService wsFirstQuestion = new WebService(ExamURL.getAnswerURL(),answerParameters,new WebService.OnPostExecuteListener() {

                public void onPostExecute(String wsResponse) {

                    JSONObject jsonObject;
                    String status = null;
                    try {
                        jsonObject = new JSONObject(wsResponse);
                        status =(String)jsonObject.get("status");
                    } catch (JSONException e) {
                        /**write the error in to log file  */
                        //again call qabackend if json is null 

                    }


                        if(status.equals("1"))

                        {
                            if(encQues==null)
                            {
                                pn=2;
                                Log.d("Making i = 2 as encQues==null"," in callQABackEnd");
                                getQuestion(newQNo);
                            }

                            else
                            {
                                Log.d("","getting questions from database");
                                String answer = db.displayAnswer(QNo);
                                String qnno = Integer.toString(QNo);
                                Log.d("Question From BackEnd",qnno);
                                Log.d("ANSWER FROM QABACKEND",answer);
                                constructQuestionOnScreen(newQNo,encQues);

                            }

                        }
                        else 
                            Log.d("","ANSWER Upload failure.WEBSERVICE response "+wsResponse);

                    }
                }); wsFirstQuestion.execute();
                }
            else
                 {
                     Log.d("answerChangeFlag","in else statement");

                     if(encQues==null)
                        {
                         pn=2;
                            Log.d("Making i = 2 as encQues==null"," in callQABackEnd");
                            getQuestion(newQNo);
                        }

                     else
                        {
                            Log.d("","getting questions from database");
                            String answer = db.displayAnswer(QNo);
                            String qnno = Integer.toString(QNo);
                            Log.d("Question From BackEnd",qnno);
                            Log.d("ANSWER FROM QABACKEND",answer);
                            constructQuestionOnScreen(newQNo,encQues);

                        }

                 }

             }catch(Exception e)
                { 
                     Log.d("Error**** ",  e.toString());    
                }

    }

    private  void getQuestion(int qNo)
    {
        final int qno = qNo;


            try{    


                ArrayList&lt;NameValuePair&gt; questionParameters = new ArrayList&lt;NameValuePair&gt;();
                questionParameters.add(new BasicNameValuePair("rollNumber", StudentInformation.getRollNumber()));
                questionParameters.add(new BasicNameValuePair("reqQNo",Integer.toString(qno)));
                WebService wsFirstQuestion = new WebService(ExamURL.getQuestionURL(),questionParameters,new WebService.OnPostExecuteListener() {

                public void onPostExecute(String wsResponse) {

                    String EncryptedQues = wsResponse;

                    db.insertQuestionToQA(qno,EncryptedQues);


                    constructQuestionOnScreen(qno,EncryptedQues);   


                }
                }); wsFirstQuestion.execute();



        }
        catch (Exception e)
        {

            Log.d("Error : ",  e.toString());
        }

    }   
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)  {
        if (keyCode == KeyEvent.KEYCODE_BACK &amp;&amp; event.getRepeatCount() == 0) {
            onBackPressed();
        }

        return super.onKeyDown(keyCode, event);
    }
    @Override
    public void onBackPressed() {
        callQABackEnd(QNo);
        clickedFinish();
        return;
    }
</code></pre>

<p>}</p>

<p><strong>Webservice.java</strong></p>

<p>public class WebService extends AsyncTask {</p>

<pre><code>private OnPostExecuteListener mPostExecuteListener = null;
private ArrayList&lt;NameValuePair&gt;     mParams;
private String urlName;

public static interface OnPostExecuteListener
{
    void onPostExecute(String wsResponse);
}

WebService (String URLName,ArrayList&lt;NameValuePair&gt; nameValuePairs, OnPostExecuteListener postExecuteListener) throws Exception
{

    mParams = nameValuePairs;
    urlName = URLName;
    mPostExecuteListener = postExecuteListener;
    if (mPostExecuteListener == null)
        throw new Exception("Param cannot be null.");

}


@Override
protected String doInBackground(URL... params) {
    // TODO Auto-generated method stub
    String result = null;
    String j="err";
    try
    {
    final int examHTTP_TIMEOUT = 30 * 1000; // milliseconds
     Log.i("Entering Background process ",j);

    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();

     final HttpParams params1 = httpclient.getParams();
     HttpConnectionParams.setConnectionTimeout(params1, examHTTP_TIMEOUT);
     HttpConnectionParams.setSoTimeout(params1, examHTTP_TIMEOUT);
     ConnManagerParams.setTimeout(params1, examHTTP_TIMEOUT);



     HttpPost httppost = new HttpPost(urlName);

        // Add parameters
        httppost.setEntity(new UrlEncodedFormEntity(mParams));
        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        if (entity != null)
        {
            InputStream inStream = entity.getContent();
            result = convertStreamToString(inStream);
            Log.i("response ", result);

        }

      return result;

      }
      catch (ClientProtocolException e)
      {
             return e.toString();
      } 
      catch(IOException e)
      {
              return e.toString();
      }
      catch (Exception e)
      {
              return e.toString();
      }

}


 @Override
 protected void onPostExecute(String wsResponse)
 {
    if (mPostExecuteListener != null)
     {
        mPostExecuteListener.onPostExecute(wsResponse);

     }

   }
 private static String convertStreamToString(InputStream is)
 {
     BufferedReader reader = new BufferedReader(
     new InputStreamReader(is));
     StringBuilder sb = new StringBuilder();
     String line = null;
     try
     {
         while ((line = reader.readLine()) != null) {
             sb.append(line + "\n");
         }
      }
     catch (IOException e)
     {
         e.printStackTrace();

     }
     finally
     {
         try
         {
             is.close();
         }
         catch (IOException e)
         {
             e.printStackTrace();

         }
     }
     return sb.toString();
 }
</code></pre>

<p>}</p>
