通过 HTTP 解析 XML 时出错

发布于 2024-10-27 07:22:45 字数 12174 浏览 1 评论 0原文

在此给定的代码中,我的 HTTP 相关代码工作正常,并且在 toast 消息中给出了正确的结果。但是,当我应用 HTTP 内容 (XML) 解析时,它将强制关闭。

我在这里所做的具体问题是什么?

public class Player extends Activity {

    String d="";
    TextView id[];
    TextView name[];
     String str;
    TableLayout t1;
    private HttpEntity responseEntity;

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

        TableLayout t1 = (TableLayout) findViewById(R.id.myTable);

       Intent i = getIntent();
        Bundle b = i.getExtras();
        String str = b.getString("ARRIVING_FROM");

        TextView title = (TextView) findViewById(R.id.TextView01);
        title.setText(str);

            d=d+"";
            d = tryLogin(str);
            System.out.println("Value of D"+d.substring(0, 1));
            if(d.substring(0, 1).equalsIgnoreCase("1"))
            //if(d.equals(str))
            {

                Toast.makeText(getApplicationContext(), "OOPS", Toast.LENGTH_SHORT).show();
            }
    else
        Toast.makeText(getApplicationContext(), d, Toast.LENGTH_SHORT).show();

     try
        {
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();

            XMLHandler myXMLHandler = new XMLHandler();
            xr.setContentHandler(myXMLHandler);
            xr.parse(retrieveInputStream(responseEntity));
            } catch (Exception e) {
                System.out.println("XML Parsing Excpetion = " + e);
        }


        final ScoreList scorelist = XMLHandler.scorelist ;

        id = new TextView[scorelist.getName().size()];
        name = new TextView[scorelist.getName().size()];

        for (int i1 = 0; i1 < scorelist.getName().size(); i1++) {

            TableRow tr = new TableRow(this);
            tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 

             id[i1]= new TextView(this);
             id[i1].setText(scorelist.getId().get(i1));
             id[i1].setTextColor(Color.WHITE);
             id[i1].setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));

             tr.addView(id[i1]);

             name[i1]= new TextView(this);
             name[i1].setText(scorelist.getName().get(i1));
             name[i1].setTextColor(Color.WHITE);
             name[i1].setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
             tr.addView(name[i1]);


             t1.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));  
        }
   }  

                private InputSource retrieveInputStream(HttpEntity responseEntity) {
        // TODO Auto-generated method stub
        return null;
    }

                protected String tryLogin(String str)
                {

                             DefaultHttpClient client = new DefaultHttpClient();
                             HttpPost httppost = new HttpPost("http://ip_address/test/player_details.php?player_id="+str.replace(' ', '+'));
                             List nvps = new ArrayList();
                             nvps.add(new BasicNameValuePair("player_id", str));

                             try 
                             {


                                  UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(nvps,HTTP.UTF_8);
                                   httppost.setEntity(p_entity);
                                   HttpResponse response = client.execute(httppost);
                                   Log.v("MyPlayerInfo", response.getStatusLine().toString());
                                   HttpEntity responseEntity = response.getEntity();
                                  InputStream in=responseEntity.getContent();
                                  byte[] bData = new byte[1024];

                                    in.read(bData);
                                    System.out.println("In Data"+in.toString());
                                    String st=new String (bData);
                                    d =st;
                                    System.out.println("Response String from server"+st);
                                    Log.v("MyPlayerInfo", "Set response to responseEntity");
                                    return d;
                                   } catch(Exception e)
                                   {
                                       Log.i("Catch","Exception generate in Post");
                                       e.printStackTrace();
                                       }return"0";
                                   }
}

logcat 响应:

是的,这是我的 logcat 响应:

03-29 17:01:24.028: DEBUG/AndroidRuntime(2300): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-29 17:01:24.028: DEBUG/AndroidRuntime(2300): CheckJNI is ON
03-29 17:01:24.218: DEBUG/AndroidRuntime(2300): --- registering native functions ---
03-29 17:01:24.988: DEBUG/AndroidRuntime(2300): Shutting down VM
03-29 17:01:24.998: DEBUG/dalvikvm(2300): Debugger has detached; object registry had 1 entries
03-29 17:01:25.028: INFO/AndroidRuntime(2300): NOTE: attach of thread 'Binder Thread #3' failed
03-29 17:01:36.128: INFO/System.out(2314): Response String from server1ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ
03-29 17:01:36.128: VERBOSE/MyParsingExample(2314): Set response to responseEntity
03-29 17:01:36.128: INFO/System.out(2314): Value of D1
03-29 17:01:36.138: INFO/ActivityManager(43): Starting activity: Intent { cmp=android.example/.MyPlayerInfo (has extras) }
03-29 17:01:36.408: DEBUG/dalvikvm(2314): GC_FOR_MALLOC freed 3151 objects / 182456 bytes in 85ms
03-29 17:01:36.508: VERBOSE/MyPlayerInfo(2314): HTTP/1.1 200 OK
03-29 17:01:36.508: INFO/System.out(2314): In Dataorg.apache.http.conn.EofSensorInputStream@43eaac68
03-29 17:01:36.528: INFO/System.out(2314): Response String from server<result>
03-29 17:01:36.528: INFO/System.out(2314):                     <playerid>1</player_id>
03-29 17:01:36.528: INFO/System.out(2314):                     <player_name>Sachin Tendulkar</player_name>
03-29 17:01:36.538: INFO/System.out(2314):                  </result>ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ
03-29 17:01:36.538: VERBOSE/MyPlayerInfo(2314): Set response to responseEntity
03-29 17:01:36.538: INFO/System.out(2314): Value of D<
03-29 17:01:36.568: INFO/System.out(2314): XML Parsing Excpetion = java.lang.NullPointerException
03-29 17:01:36.578: DEBUG/AndroidRuntime(2314): Shutting down VM
03-29 17:01:36.578: WARN/dalvikvm(2314): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314): FATAL EXCEPTION: main
03-29 17:01:36.598: ERROR/AndroidRuntime(2314): java.lang.RuntimeException: Unable to start activity ComponentInfo{android.example/android.example.MyPlayerInfo}: java.lang.NullPointerException
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.os.Looper.loop(Looper.java:123)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at java.lang.reflect.Method.invokeNative(Native Method)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at java.lang.reflect.Method.invoke(Method.java:521)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at dalvik.system.NativeStart.main(Native Method)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314): Caused by: java.lang.NullPointerException
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.example.MyPlayerInfo.onCreate(MyPlayerInfo.java:91)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     ... 11 more
03-29 17:01:36.618: WARN/ActivityManager(43):   Force finishing activity android.example/.MyPlayerInfo
03-29 17:01:36.628: WARN/ActivityManager(43):   Force finishing activity android.example/.MyParsingExample
03-29 17:01:37.174: WARN/ActivityManager(43): Activity pause timeout for HistoryRecord{44051d20 android.example/.MyPlayerInfo}
03-29 17:01:38.508: INFO/Process(2314): Sending signal. PID: 2314 SIG: 9
03-29 17:01:38.538: INFO/ActivityManager(43): Process android.example (pid 2314) has died.
03-29 17:01:38.538: INFO/WindowManager(43): WIN DEATH: Window{440299d8 android.example/android.example.MyParsingExample paused=true}
03-29 17:01:38.578: WARN/NotificationService(43): Object died trying to hide notification android.app.ITransientNotification$Stub$Proxy@440bf590 in package android.example
03-29 17:01:38.578: WARN/ActivityManager(43): setProcessForeground called on unknown pid: 2314
03-29 17:01:38.688: WARN/InputManagerService(43): Got RemoteException sending setActive(false) notification to pid 2314 uid 10074
03-29 17:01:47.592: WARN/ActivityManager(43): Activity destroy timeout for HistoryRecord{43f68630 android.example/.MyParsingExample}
03-29 17:01:47.592: WARN/ActivityManager(43): Activity destroy timeout for HistoryRecord{44051d20 android.example/.MyPlayerInfo}

In this given code, my HTTP-related code is working correctly and it is giving correct result in toast message. However when I apply parsing of the HTTP content (XML), it will force close.

What is the exact problem with what I'm doing here?

public class Player extends Activity {

    String d="";
    TextView id[];
    TextView name[];
     String str;
    TableLayout t1;
    private HttpEntity responseEntity;

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

        TableLayout t1 = (TableLayout) findViewById(R.id.myTable);

       Intent i = getIntent();
        Bundle b = i.getExtras();
        String str = b.getString("ARRIVING_FROM");

        TextView title = (TextView) findViewById(R.id.TextView01);
        title.setText(str);

            d=d+"";
            d = tryLogin(str);
            System.out.println("Value of D"+d.substring(0, 1));
            if(d.substring(0, 1).equalsIgnoreCase("1"))
            //if(d.equals(str))
            {

                Toast.makeText(getApplicationContext(), "OOPS", Toast.LENGTH_SHORT).show();
            }
    else
        Toast.makeText(getApplicationContext(), d, Toast.LENGTH_SHORT).show();

     try
        {
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();

            XMLHandler myXMLHandler = new XMLHandler();
            xr.setContentHandler(myXMLHandler);
            xr.parse(retrieveInputStream(responseEntity));
            } catch (Exception e) {
                System.out.println("XML Parsing Excpetion = " + e);
        }


        final ScoreList scorelist = XMLHandler.scorelist ;

        id = new TextView[scorelist.getName().size()];
        name = new TextView[scorelist.getName().size()];

        for (int i1 = 0; i1 < scorelist.getName().size(); i1++) {

            TableRow tr = new TableRow(this);
            tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 

             id[i1]= new TextView(this);
             id[i1].setText(scorelist.getId().get(i1));
             id[i1].setTextColor(Color.WHITE);
             id[i1].setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));

             tr.addView(id[i1]);

             name[i1]= new TextView(this);
             name[i1].setText(scorelist.getName().get(i1));
             name[i1].setTextColor(Color.WHITE);
             name[i1].setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
             tr.addView(name[i1]);


             t1.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));  
        }
   }  

                private InputSource retrieveInputStream(HttpEntity responseEntity) {
        // TODO Auto-generated method stub
        return null;
    }

                protected String tryLogin(String str)
                {

                             DefaultHttpClient client = new DefaultHttpClient();
                             HttpPost httppost = new HttpPost("http://ip_address/test/player_details.php?player_id="+str.replace(' ', '+'));
                             List nvps = new ArrayList();
                             nvps.add(new BasicNameValuePair("player_id", str));

                             try 
                             {


                                  UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(nvps,HTTP.UTF_8);
                                   httppost.setEntity(p_entity);
                                   HttpResponse response = client.execute(httppost);
                                   Log.v("MyPlayerInfo", response.getStatusLine().toString());
                                   HttpEntity responseEntity = response.getEntity();
                                  InputStream in=responseEntity.getContent();
                                  byte[] bData = new byte[1024];

                                    in.read(bData);
                                    System.out.println("In Data"+in.toString());
                                    String st=new String (bData);
                                    d =st;
                                    System.out.println("Response String from server"+st);
                                    Log.v("MyPlayerInfo", "Set response to responseEntity");
                                    return d;
                                   } catch(Exception e)
                                   {
                                       Log.i("Catch","Exception generate in Post");
                                       e.printStackTrace();
                                       }return"0";
                                   }
}

logcat response:

yes this is my logcat response:

03-29 17:01:24.028: DEBUG/AndroidRuntime(2300): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-29 17:01:24.028: DEBUG/AndroidRuntime(2300): CheckJNI is ON
03-29 17:01:24.218: DEBUG/AndroidRuntime(2300): --- registering native functions ---
03-29 17:01:24.988: DEBUG/AndroidRuntime(2300): Shutting down VM
03-29 17:01:24.998: DEBUG/dalvikvm(2300): Debugger has detached; object registry had 1 entries
03-29 17:01:25.028: INFO/AndroidRuntime(2300): NOTE: attach of thread 'Binder Thread #3' failed
03-29 17:01:36.128: INFO/System.out(2314): Response String from server1ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ
03-29 17:01:36.128: VERBOSE/MyParsingExample(2314): Set response to responseEntity
03-29 17:01:36.128: INFO/System.out(2314): Value of D1
03-29 17:01:36.138: INFO/ActivityManager(43): Starting activity: Intent { cmp=android.example/.MyPlayerInfo (has extras) }
03-29 17:01:36.408: DEBUG/dalvikvm(2314): GC_FOR_MALLOC freed 3151 objects / 182456 bytes in 85ms
03-29 17:01:36.508: VERBOSE/MyPlayerInfo(2314): HTTP/1.1 200 OK
03-29 17:01:36.508: INFO/System.out(2314): In Dataorg.apache.http.conn.EofSensorInputStream@43eaac68
03-29 17:01:36.528: INFO/System.out(2314): Response String from server<result>
03-29 17:01:36.528: INFO/System.out(2314):                     <playerid>1</player_id>
03-29 17:01:36.528: INFO/System.out(2314):                     <player_name>Sachin Tendulkar</player_name>
03-29 17:01:36.538: INFO/System.out(2314):                  </result>ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ
03-29 17:01:36.538: VERBOSE/MyPlayerInfo(2314): Set response to responseEntity
03-29 17:01:36.538: INFO/System.out(2314): Value of D<
03-29 17:01:36.568: INFO/System.out(2314): XML Parsing Excpetion = java.lang.NullPointerException
03-29 17:01:36.578: DEBUG/AndroidRuntime(2314): Shutting down VM
03-29 17:01:36.578: WARN/dalvikvm(2314): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314): FATAL EXCEPTION: main
03-29 17:01:36.598: ERROR/AndroidRuntime(2314): java.lang.RuntimeException: Unable to start activity ComponentInfo{android.example/android.example.MyPlayerInfo}: java.lang.NullPointerException
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.os.Looper.loop(Looper.java:123)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at java.lang.reflect.Method.invokeNative(Native Method)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at java.lang.reflect.Method.invoke(Method.java:521)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at dalvik.system.NativeStart.main(Native Method)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314): Caused by: java.lang.NullPointerException
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.example.MyPlayerInfo.onCreate(MyPlayerInfo.java:91)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-29 17:01:36.598: ERROR/AndroidRuntime(2314):     ... 11 more
03-29 17:01:36.618: WARN/ActivityManager(43):   Force finishing activity android.example/.MyPlayerInfo
03-29 17:01:36.628: WARN/ActivityManager(43):   Force finishing activity android.example/.MyParsingExample
03-29 17:01:37.174: WARN/ActivityManager(43): Activity pause timeout for HistoryRecord{44051d20 android.example/.MyPlayerInfo}
03-29 17:01:38.508: INFO/Process(2314): Sending signal. PID: 2314 SIG: 9
03-29 17:01:38.538: INFO/ActivityManager(43): Process android.example (pid 2314) has died.
03-29 17:01:38.538: INFO/WindowManager(43): WIN DEATH: Window{440299d8 android.example/android.example.MyParsingExample paused=true}
03-29 17:01:38.578: WARN/NotificationService(43): Object died trying to hide notification android.app.ITransientNotification$Stub$Proxy@440bf590 in package android.example
03-29 17:01:38.578: WARN/ActivityManager(43): setProcessForeground called on unknown pid: 2314
03-29 17:01:38.688: WARN/InputManagerService(43): Got RemoteException sending setActive(false) notification to pid 2314 uid 10074
03-29 17:01:47.592: WARN/ActivityManager(43): Activity destroy timeout for HistoryRecord{43f68630 android.example/.MyParsingExample}
03-29 17:01:47.592: WARN/ActivityManager(43): Activity destroy timeout for HistoryRecord{44051d20 android.example/.MyPlayerInfo}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

转角预定愛 2024-11-03 07:22:45

您在 MyPlayerInfo 第 91 行的 onCreate() 方法中出现了 NullPointerException

另外,切勿在主应用程序线程上进行网络 I/O 和解析。请使用 AsyncTask 或其他形式的后台线程。

You have a NullPointerException on line 91 of MyPlayerInfo, in the onCreate() method.

Also, never do network I/O and parsing on the main application thread. Use an AsyncTask or some other form of background thread, please.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文