Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java handler.getQueryResponse(流)处的NullPointerException;_Java_Android_Arrays_Inputstream - Fatal编程技术网

Java handler.getQueryResponse(流)处的NullPointerException;

Java handler.getQueryResponse(流)处的NullPointerException;,java,android,arrays,inputstream,Java,Android,Arrays,Inputstream,我在这行得到一个NullPointerException: handler.getQueryResponse(stream); 我已经看过源代码好几次了,我不确定为什么会发生这种情况 如有任何建议,我们将不胜感激 日志: 08-16 16:26:24.401: E/AndroidRuntime(9542): FATAL EXCEPTION: main 08-16 16:26:24.401: E/AndroidRuntime(9542): java.lang.NullPoint

我在这行得到一个NullPointerException:

 handler.getQueryResponse(stream);
我已经看过源代码好几次了,我不确定为什么会发生这种情况

如有任何建议,我们将不胜感激

日志:

    08-16 16:26:24.401: E/AndroidRuntime(9542): FATAL EXCEPTION: main
    08-16 16:26:24.401: E/AndroidRuntime(9542): java.lang.NullPointerException
    08-16 16:26:24.401: E/AndroidRuntime(9542):     at com.project.new.datasettings.UpdateActivity.success(UpdateActivity.java:426)
    08-16 16:26:24.401: E/AndroidRuntime(9542):     at com.project.new.datasettings.UpdateActivity$NetworkTask.onPostExecute(UpdateActivity.java:389)
    08-16 16:26:24.401: E/AndroidRuntime(9542):     at com.project.new.datasettings.UpdateActivity$NetworkTask.onPostExecute(UpdateActivity.java:1)
资料来源:

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
import java.util.zip.GZIPInputStream;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLException;
import javax.xml.parsers.ParserConfigurationException;
import com.project.new.datasettings.XmlParserHandlerFinal;
import org.xml.sax.SAXException;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.SQLException;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.ClipDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.StrictMode;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

import com.project.new.datasettings.R;

public class UpdateActivity extends Activity implements OnClickListener {
    public static ArrayList<String> NameArr = new ArrayList<String>();
    public static ArrayList<String> ValueArr = new ArrayList<String>();
    public static ArrayList<String> nameArr = new ArrayList<String>();
    public static ArrayList<String> ApnArr = new ArrayList<String>();
    public static ArrayList<String> mmscArr = new ArrayList<String>();
    public static ArrayList<String> mmsportArr = new ArrayList<String>();
    public static ArrayList<String> mmsproxyArr = new ArrayList<String>();
    public static ArrayList<String> portArr = new ArrayList<String>();
    public static ArrayList<String> proxyArr = new ArrayList<String>();
    private ImageView mProgressImageview1;
    private ImageView mProgressImageview2;
    private ImageView mProgressImageview3;
    private ImageView mProgressImageview4;
    private ImageView mProgressImageview5;
    public static int count;
    AlertDialog mErrorAlert = null;
    int version;
    public static int TotalSteps = 8;
    private TelephonyManager tm;
    private static final String LOG_TAG = "STDataSettings";
    private Button mUpdateButton = null;
    private Button mAssistUpdateButton = null;
    private Button mAssistInstrButton = null;
    private TextView mReadAgainButton = null;
    private int mInstructionNumber = 0;
    AlertDialog mConfirmAlert = null;
    public static InputStream stream = null;
    public static XmlParserHandlerFinal handler;
    private NetworkTask task;
    private AnimationDrawable loadingAnimation;
    private static final String TAG = "UpdateActivity";
    Context ctx;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
        int networkType = tm.getNetworkType();
        int phoneType = tm.getPhoneType();
        int version = android.os.Build.VERSION.SDK_INT;
        if (phoneType == TelephonyManager.PHONE_TYPE_CDMA
                || (phoneType != TelephonyManager.PHONE_TYPE_GSM
                && networkType != TelephonyManager.NETWORK_TYPE_GPRS
                && networkType != TelephonyManager.NETWORK_TYPE_EDGE
                && networkType != TelephonyManager.NETWORK_TYPE_HSDPA
                && networkType != TelephonyManager.NETWORK_TYPE_HSPA
                && networkType != TelephonyManager.NETWORK_TYPE_HSPAP
                && networkType != TelephonyManager.NETWORK_TYPE_HSUPA
                && networkType != TelephonyManager.NETWORK_TYPE_UMTS && networkType != TelephonyManager.NETWORK_TYPE_LTE)) {
            // If the phone type is CDMA or
            // the phone phone type is not GSM and the network type is none of
            // the network types indicated in the statement
            // Display incompatibility message
            showAlert(getString(R.string.incomp_sm_dialog));
            // Network type is looked because some tablets have no phone type.
            // We rely on network type in such cases
        } else if (!(tm.getSimState() == TelephonyManager.SIM_STATE_ABSENT
                || (tm.getSimOperator())
                .equals(getString(R.string.numeric_tmo)) || (tm
                        .getSimOperator()).equals(getString(R.string.numeric_att)))) {
            // if SIM is present and is NOT a T-Mo network SIM,
            // display Error message alert indicating to use SM SIM
            showAlert(getString(R.string.insert_sm_dialog));
        }// No SIM or SIM with T-Mo MNC MCC present
        else if (version < VERSION_CODES.ICE_CREAM_SANDWICH) {
            // Initial UI setup for versions lower than ICS
            setContentView(R.layout.update);
            mUpdateButton = (Button) findViewById(R.id.update_button);

            mUpdateButton.setOnClickListener(this);
        } else {// ICS and up

            // task.execute();

            if ((tm.getSimOperator()).equals(getString(R.string.numeric_tmo))
                    || (tm.getSimOperator())
                    .equals(getString(R.string.numeric_att))) {
                task = new NetworkTask();
                task.execute("");
                // Device has T-Mo network SIM card MCC and MNC correctly
                // populated
                // Reduce number of steps to 6
                TotalSteps = 6;
            }

        }
    }

    public void onClick(View v) {

        if (v == mUpdateButton) {
            // Update button for versions lower than ICS is selected
            // setContentView(R.layout.updating);
            onClickMethod(v);

            Intent i = new Intent(this, ConfigFinalActivity.class);
            startActivity(i);
            finish();
        } else if (v == mAssistUpdateButton) {

            // Update button for ICS and up is selected
            // Get the TextView in the Assist Update UI
            TextView tv = (TextView) findViewById(R.id.apn_app_text_cta2);
            String text = "";
            CharSequence styledText = text;
            switch (mInstructionNumber) {
            case 0:
                // Retrieve the instruction string resource corresponding the
                // 2nd set of instructions
                text = String.format(getString(R.string.apn_app_text_instr),
                        TotalSteps);
                styledText = Html.fromHtml(text);
                // Update the TextView with the correct set of instructions
                tv.setText(styledText);
                // Increment instruction number so the correct instructions
                // string resource can be retrieve the next time the update
                // button is pressed
                mInstructionNumber++;
                break;
            case 1:
                text = getString(R.string.apn_app_text_instr2);
                styledText = Html.fromHtml(text);
                tv.setText(styledText);
                // Increment instruction number so the correct instructions
                // string resource can be retrieve the next time the update
                // button is pressed
                mInstructionNumber++;
                break;
            case 2:
                // Final set of instructions-Change to the corresponding layout

                setContentView(R.layout.assist_instructions);
                String assistUpdateInstr = String.format(
                        getString(R.string.apn_app_text_instr3), TotalSteps);
                styledText = Html.fromHtml(assistUpdateInstr);
                TextView assistInstrText = (TextView) findViewById(R.id.updated_text);
                assistInstrText.setText(styledText);
                mAssistInstrButton = (Button) findViewById(R.id.assist_instr_btn);
                mReadAgainButton = (TextView) findViewById(R.id.read_again_btn);
                mAssistInstrButton.setOnClickListener(this);
                mReadAgainButton.setOnClickListener(this);
            }
        } else if (v == mAssistInstrButton) {
            // "LET'S DO THIS" Button in final instructions screen for ICS and
            // up is selected
            // Create ConfigActivity Intent
            Intent i = new Intent(this, ConfigFinalActivity.class);
            // Invoke ConfigActivity Intent to start the assisted update
            startActivity(i);
            finish();
        } else if (v == mReadAgainButton) {
            // go back to 1st set of instructions if read again is selected
            mInstructionNumber = 0;
            setContentView(R.layout.assist_update);
            String assistUpdate = getString(R.string.apn_app_text_cta2);
            CharSequence styledText = Html.fromHtml(assistUpdate);
            TextView assistText = (TextView) findViewById(R.id.apn_app_text_cta2);
            assistText.setText(styledText);
            mAssistUpdateButton = (Button) findViewById(R.id.assist_update_btn);
            mAssistUpdateButton.setOnClickListener(this);
        }
    }

    public void onClickMethod(View v) {
        mUpdateButton = (Button) findViewById(R.drawable.btn_update_active_hdpi);

    }

    private void showAlert(String message) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(message).setPositiveButton("OK",
                new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                UpdateActivity.this.finish();
            }
        });
        mConfirmAlert = builder.create();
        mConfirmAlert.show();
    }
    // AsyncTask to call web service
             class NetworkTask extends AsyncTask<String, Integer, InputStream> {

                @Override
                protected void onPreExecute() {

                    super.onPreExecute();
                }

                @Override
                protected InputStream doInBackground(String... params) {

                    try {
                        // saving the response in InputStream
                        stream = getQueryResults("https://dl.dropboxusercontent.com/u/31771876/GetPhoneSettings-ST-rsp-eng.xml");
                    //  stream = new BufferedInputStream(https.getInputStream());
                               DataInputStream in = new DataInputStream(stream);
                                   BufferedReader br = new BufferedReader(new InputStreamReader(in));
                                 String strLine; 
                                   while ((strLine = br.readLine()) != null) { // Print the content on the console
                                       System.out.println (strLine); 
                                   System.out.println (strLine); 
                                         in.close();
                                   }


                    } catch (IOException e) {

                        Log.v(LOG_TAG, e.toString());
                        e.printStackTrace();
                    } catch (SAXException e) {

                        Log.v(LOG_TAG, e.toString());
                        e.printStackTrace();
                    } catch (Exception e) {

                        Log.v(LOG_TAG, e.toString());
                        e.printStackTrace();
                    }
                    // The code below plays a Simple Promo animation

                    for (int incr = 0; incr < 2; incr++) {
                        // Sleep for 1/2 second
                        // Invoke UI to change updating text to show 1 dot
                        // And Increasing the level to reduce the amount of clipping and
                        // slowly reveals the hand image
                        publishProgress(R.drawable.loading_full,
                                R.drawable.loading_empty, R.drawable.loading_empty,
                                R.drawable.loading_empty, R.drawable.loading_empty);
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            Log.d(TAG, "sleep failure");
                        }
                        publishProgress(R.drawable.loading_full,
                                R.drawable.loading_full, R.drawable.loading_empty,
                                R.drawable.loading_empty, R.drawable.loading_empty);
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            Log.d(TAG, "sleep failure");
                        }
                        publishProgress(R.drawable.loading_full,
                                R.drawable.loading_full, R.drawable.loading_full,
                                R.drawable.loading_empty, R.drawable.loading_empty);
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            Log.d(TAG, "sleep failure");
                        }
                        publishProgress(R.drawable.loading_full,
                                R.drawable.loading_full, R.drawable.loading_full,
                                R.drawable.loading_full, R.drawable.loading_empty);
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            Log.d(TAG, "sleep failure");
                        }
                        publishProgress(R.drawable.loading_full,
                                R.drawable.loading_full, R.drawable.loading_full,
                                R.drawable.loading_full, R.drawable.loading_full);

                        // Sleep for 1/2 second
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            Log.d(TAG, "sleep failure");
                        }
                    }
                    return stream;
                }
                    /*
                     * Sends a query to server and gets back the parsed results in a bundle
                     * urlQueryString - URL for calling the webservice
                     */
                    protected synchronized InputStream getQueryResults(String urlQueryString)
                            throws IOException, SAXException, SSLException,
                            SocketTimeoutException, Exception {
                        // HttpsURLConnection https = null;


                        HttpsURLConnection https = null;
                        String uri = urlQueryString;

                        URL urlo = new URL(uri);

                        try {
                            https = (HttpsURLConnection) urlo.openConnection();
                            https.setConnectTimeout(20000); // 20 second timeout
                            https.setRequestProperty("Connection", "Keep-Alive");

                            if ("gzip".equals(https.getContentEncoding())) {
                                stream = new GZIPInputStream(stream);
                            } else
                                stream = https.getInputStream();

                        } catch (SSLException e) {
                            Log.e(LOG_TAG, e.toString());
                            e.printStackTrace();

                        } catch (SocketTimeoutException e) {
                            Log.e(LOG_TAG, e.toString());
                            e.printStackTrace();
                        } catch (IOException e) {
                            Log.e(LOG_TAG, e.toString());
                            e.printStackTrace();

                        } catch (Exception e) {
                            Log.e(LOG_TAG, e.toString());
                            e.printStackTrace();

                        } finally {
                            // https.disconnect();
                        }

                        return stream;
                    }

                    @Override
                    protected void onProgressUpdate(Integer... progress) {

                        // Call function to update image view

                        setProgressImgView(progress[0], progress[1], progress[2], progress[3], progress[4]);

                    }

                    @Override
                    protected void onPostExecute(InputStream stream) {
                        super.onPostExecute(stream);
            // This method is called to parse the response and save the ArrayLists
                        success();

                    }

                }

                private void setProgressImgView(Integer imageViewId1, Integer imageViewId2, Integer imageViewId3, Integer imageViewId4, Integer imageViewId5) {
                    // update image view with the updating dots
                    // Reset view layout in case orientation while updating
                    setContentView(R.layout.updating);

                    mProgressImageview1 = (ImageView) findViewById(R.id.loading_empty1);
                    mProgressImageview1.setBackgroundResource(imageViewId1);
                    mProgressImageview2 = (ImageView) findViewById(R.id.loading_empty2);
                    mProgressImageview1.setBackgroundResource(imageViewId2);
                    mProgressImageview3 = (ImageView) findViewById(R.id.loading_empty3);
                    mProgressImageview1.setBackgroundResource(imageViewId3);
                    mProgressImageview4 = (ImageView) findViewById(R.id.loading_empty4);
                    mProgressImageview1.setBackgroundResource(imageViewId4);
                    mProgressImageview5 = (ImageView) findViewById(R.id.loading_empty5);
                    mProgressImageview1.setBackgroundResource(imageViewId5);

                }

                @Override
                protected void onRestart() {
                    super.onRestart();

                    if (mErrorAlert != null)
                        mErrorAlert.dismiss();
                }


                public void success() {

                    // to parse the response
                    try {
                        handler.getQueryResponse(stream);

                    } catch (SAXException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    // to set method to save the ArryaLists from the parser
                    setArrayList();
                    Intent i = new Intent(this, ConfigFinalActivity.class);
                    startActivity(i);
                    finish();

                }
                // method to save the ArrayLists from parser
                public static void setArrayList() {
                    nameArr = handler.getnameArr();
                    ApnArr = handler.getApnArr();
                    mmscArr = handler.getMMSCArr();
                    mmsproxyArr = handler.getMmscProxyArr();
                    mmsportArr = handler.getMmsPortArr();
                    proxyArr = handler.getMmscProxyArr();
                    portArr = handler.getMmsPortArr();
                    count = handler.getCount();
                    //System.out.println("testing123");


                    for(int i = 0; i < nameArr.size()-1; i++){
                        System.out.println(nameArr.get(i));
                    }


                    for(int i = 0; i < ApnArr.size()-1; i++){
                        System.out.println(ApnArr.get(i));
                    }
                }
            }
导入java.io.BufferedReader;
导入java.io.DataInputStream;
导入java.io.IOException;
导入java.io.InputStream;
导入java.io.InputStreamReader;
导入java.math.biginger;
导入java.net.SocketTimeoutException;
导入java.net.URL;
导入java.util.ArrayList;
导入java.util.concurrent.ExecutionException;
导入java.util.zip.gzip输入流;
导入javax.net.ssl.HttpsURLConnection;
导入javax.net.ssl.SSLException;
导入javax.xml.parsers.parserConfiguration异常;
导入com.project.new.datasettings.xmlparserhanderfinal;
导入org.xml.sax.SAXException;
导入android.annotation.TargetApi;
导入android.app.Activity;
导入android.app.AlertDialog;
导入android.app.Notification;
导入android.app.NotificationManager;
导入android.app.pendingent;
导入android.content.ContentResolver;
导入android.content.ContentValues;
导入android.content.Context;
导入android.content.DialogInterface;
导入android.content.Intent;
导入android.database.Cursor;
导入android.database.SQLException;
导入android.graphics.drawable.AnimationDrawable;
导入android.graphics.drawable.ClipDrawable;
导入android.net.Uri;
导入android.os.AsyncTask;
导入android.os.Build;
导入android.os.Build.VERSION\u代码;
导入android.os.Bundle;
导入android.os.StrictMode;
导入android.provider.Settings;
导入android.telephony.TelephonyManager;
导入android.util.Log;
导入android.view.LayoutInflater;
导入android.view.view;
导入android.view.view.OnClickListener;
导入android.widget.Button;
导入android.widget.ImageView;
导入com.project.new.datasettings.R;
公共类UpdateActivity扩展了活动实现OnClickListener{
public static ArrayList NameArr=new ArrayList();
public static ArrayList ValueArr=new ArrayList();
public static ArrayList nameArr=new ArrayList();
public static ArrayList ApnArr=new ArrayList();
public static ArrayList mmscArr=new ArrayList();
public static ArrayList mmsportArr=new ArrayList();
public static ArrayList mmsproxyArr=new ArrayList();
public static ArrayList portArr=new ArrayList();
public static ArrayList proxyArr=new ArrayList();
私有图像视图mProgressImageview1;
私有图像视图mProgressImageview2;
私有图像视图mProgressImageview3;
私有图像视图mProgressImageview4;
私有图像视图mprogressimageview 5;
公共静态整数计数;
AlertDialog mErrorAlert=null;
int版本;
公共静态int TotalSteps=8;
专用电话管理器tm;
私有静态最终字符串日志\u TAG=“STDataSettings”;
私有按钮mUpdateButton=null;
private Button-DateButton=null;
私有按钮mAssistInstrButton=null;
私有文本视图mReadAgainButton=null;
私有int mInstructionNumber=0;
AlertDialog mConfirmAlert=null;
公共静态InputStream=null;
公共静态XmlParserHandlerFinal处理程序;
专用网络任务;
私有动画绘制可加载动画;
私有静态最终字符串TAG=“UpdateActivity”;
上下文ctx;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
tm=(电话管理器)getSystemService(电话服务);
int networkType=tm.getNetworkType();
int phoneType=tm.getPhoneType();
int version=android.os.Build.version.SDK\u int;
if(phoneType==TelephonyManager.PHONE\u TYPE\u CDMA
||(phoneType!=TelephonyManager.PHONE\u TYPE\u GSM
&&networkType!=TelephonyManager.NETWORK\u TYPE\u GPRS
&&networkType!=TelephonyManager.NETWORK\u TYPE\u EDGE
&&networkType!=TelephonyManager.NETWORK\u TYPE\u HSDPA
&&networkType!=TelephonyManager.NETWORK\u TYPE\u HSPA
&&networkType!=TelephonyManager.NETWORK\u TYPE\u HSPAP
&&networkType!=TelephonyManager.NETWORK\u TYPE\u HSUPA
&&networkType!=TelephonyManager.NETWORK\u TYPE\u UMTS&&networkType!=TelephonyManager.NETWORK\u TYPE\u LTE)){
//如果电话类型为CDMA或
//电话类型不是GSM,网络类型不是
//声明中指示的网络类型
//显示不兼容消息
showAlert(getString(R.string.incomp_sm_对话框));
//查看网络类型是因为某些平板电脑没有电话类型。
//在这种情况下,我们依赖于网络类型
}如果(!(tm.getSimState()==TelephonyManager.SIM_STATE_缺席,则为else
||(tm.getSimOperator())
.equals(getString(R.string.numeric_tmo))| |(tm
.getSimOperator()).equals(getString(R.string.numeric_att))){
//如果SIM卡存在且不是T-Mo网络SIM卡,
//显示错误消息警报,指示使用SM SIM卡
showAlert(getString(R.string.insert_sm_对话框));
}//没有SIM卡或存在T-Mo跨国公司MCC的SIM卡
否则如果(版本<版本代码.冰淇淋\u三明治){
//低于ICS版本的初始UI设置
setContentView(R.layout.update);
mUpdateButton=(按钮)findViewById(R.id.update_按钮);
mUpdateButton.setOnClickListener(此);
}else{//ICS及以上
//task.execute();
if((tm.getSimOperator()).equals(getString(R.string.numeric_tmo))
||(tm.getSimOperator())
.equals(getString(R.string.numeric_att))){
任务=新的网络任务();
任务。执行(“”);
//装置
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

import android.content.ContentValues;
import android.content.Context;
import android.os.StrictMode;
import android.util.Log;

public class XmlParserHandlerFinal extends DefaultHandler {

    public  String queryResult;
    private String name, Value;
    public  ArrayList<String> NameArr = new ArrayList<String>();
    public  ArrayList<String> ValueArr = new ArrayList<String>();
    public  ArrayList<String> nameArr = new ArrayList<String>();
    public  ArrayList<String> ApnArr = new ArrayList<String>();
    public  ArrayList<String> mmscArr = new ArrayList<String>();
    public  ArrayList<String> mmsportArr = new ArrayList<String>();
    public  ArrayList<String> mmsproxyArr = new ArrayList<String>();
    public  ArrayList<String> portArr = new ArrayList<String>();
    public  ArrayList<String> proxyArr = new ArrayList<String>();
    public  ArrayList<ContentValues> ArrValues = new ArrayList<ContentValues>();
    public  ContentValues values = new ContentValues();
    public  int count = 0;
    Context c;

    private boolean isPhoneSettings = false, isName = false, isValue = false;;

    public XmlParserHandlerFinal() {


    }

    public void setContext(Context c) {
        this.c = c;
    }

    @Override
    public void startElement(String uri, String localName, String qName,
            Attributes atts) {

        if (qName.equalsIgnoreCase("Phonesettings")) {

            isPhoneSettings = true;

        }
        if (qName.equals("name")) {
            isName = true;

        }
        if (qName.equals("value")) {
            isValue = true;

        }
    }

    public void endElement(String uri, String localName, String qName)
            throws SAXException {

        if (isPhoneSettings) {

            isPhoneSettings = false;

        }

        if (isName) {
            isName = false;
        }
        if (isValue) {

            isValue = false;
        }
    }

    public void characters(char ch[], int start, int length)
            throws SAXException {

        if (isName) {

            name = new String(ch, start, length);

            NameArr.add(name);

        }
        if (isValue) {

            Value = new String(ch, start, length);

            ValueArr.add(Value);
            values.put(name, Value);
            if (name.equals("name")) {

                nameArr.add(Value);

            } else if (name.equals("apn")) {

                ApnArr.add(Value);

            } else if (name.equals("mmsc")) {
                count++;

                mmscArr.add(Value);
            } else if (name.equals("mmsproxy")) {
                mmsproxyArr.add(Value);
            } else if (name.equals("mmsport")) {
                mmsportArr.add(Value);
            } else if (name.equals("port")) {
                portArr.add(Value);
            } else if (name.equals("proxy")) {
                proxyArr.add(Value);
            } else

                if (name.equals("type")) {
                    // System.out.println("values in parser" + values);

                    ArrValues.add(values);
                    Log.v("value", Value);
                    System.out.println("size " + ArrValues.size());

                    // ((ConfigActivityForMultiProf) context)
                    // .InsertAPN();

                    // try {
                    // ((ConfigActivityForMultiProf) context)
                    // .showNotification(values);
                    // } catch (ParserConfigurationException e) {
                    // // TODO Auto-generated catch block
                    // e.printStackTrace();
                    // }

                    /*
                     * for(int i =0;i<=NameArr.size()-1;i++){ NameArr.remove(i); }
                     * for(int i =0;i<=ValueArr.size()-1;i++){ ValueArr.remove(i); }
                     */
                }

        }

    }

    public String getQueryResponse(InputStream in) throws SAXException,
    IOException {

        try {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
            .permitAll().build();

            StrictMode.setThreadPolicy(policy);
            SAXParserFactory spf = SAXParserFactory.newInstance();
            Log.v("In the parser", "now");
            SAXParser sp;
            sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            xr.setContentHandler(this);

            xr.parse(new InputSource(in));
        } catch (ParserConfigurationException e) {

            Log.e("", "XML Handler Exception: " + e.toString());
        }

        return queryResult;
    }

    public int getCount() {
        return count;
    }

    public ArrayList<String> getNameArr() {
        for (int i = 0; i <= NameArr.size() - 1; i++) {
            System.out.println(NameArr.get(i));
        }
        return NameArr;
    }

    public ArrayList<String> getValueArr() {
        for (int i = 0; i <= ValueArr.size() - 1; i++) {
            System.out.println(ValueArr.get(i));
        }
        return ValueArr;
    }

    public ArrayList<String> getnameArr() {
        for (int i = 0; i <= nameArr.size() - 1; i++) {
            System.out.println(nameArr.get(i));
        }
        return nameArr;
    }

    public ArrayList<String> getApnArr() {
        for (int i = 0; i <= ApnArr.size() - 1; i++) {
            System.out.println(ApnArr.get(i));
        }
        return ApnArr;
    }

    public ArrayList<String> getMMSCArr() {

        return mmscArr;
    }

    public ArrayList<String> getMmscProxyArr() {

        return mmsproxyArr;
    }

    public ArrayList<String> getMmsPortArr() {

        return mmsportArr;
    }

    public ArrayList<String> getProxyArr() {

        return proxyArr;
    }

    public ArrayList<String> getPortArr() {

        return portArr;
    }

    public ArrayList<ContentValues> getArrValuesArr() {
        return ArrValues;
    }
}
public class MyClass {

    public static Object o;

public static void main(String[] args) {
     String s;
         s = o.toString(); // this will throw an exception
    }

}
public class MyClass {

    public static Object o;

    static {
       o = new Object();  // initialize the data member here
    }


    public static void main(String[] args) {
         String s;
         s = o.toString();  // now pointing to a valid object
    }

}