2013-08-13 6 views
0

내 응용 프로그램에서 구문 분석해야하는 데이터가 포함 된 XML 파일이 있지만 서버에서 XML 파일에 액세스 할 수 있는지 확인했지만 디버깅을 시도 할 때 값이 계속 null로 표시됩니다.구문 분석 XML은 항상 Null을 반환합니다.

나는 계속 내 로그 캣이를 얻을 내 코드에서 선 아래로 다른 문제가 발생합니다

08-13 17:56:39.452: I/System.out(1424): STREAM DEBUG 
08-13 17:56:39.452: I/System.out(1424): null 

모든 제안은 크게 감사하고 있습니다.

관련 소스 코드 조각 :

public class ConfigFinalActivity extends Activity implements OnClickListener { 
    private static final String TAG = "ConfigActivity"; 
    TelephonyManager tm; 
    AlertDialog mErrorAlert = null; 
    private Notification mNotification = null; 
    private Button assist_update_btn = null; 
    // Progress 
    private ImageView mProgressImageview1; 
    private ImageView mProgressImageview2; 
    private ImageView mProgressImageview3; 
    private ImageView mProgressImageview4; 
    private ImageView mProgressImageview5; 

    private int mInstructionNumber = 0; 
    UpdateActivity update; 
    public ArrayList<String> ValueArr = new ArrayList<String>(); 
    public ArrayList<String> nameArr = new ArrayList<String>(5); 
    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>(); 
    private Button mAssistInstrButton = null; 
    private TextView mReadAgainButton = null; 
    public static int TotalSteps = 8; 
    public static int count; 
    int i, g = 0; 
    Context ctx; 
    public static ContentValues Values = new ContentValues(); 
    XmlParserHandlerFinal handler; 
    public static BigInteger id1, id2; 
    BigInteger[] id; 
    public static Integer mdn1, mdn2; 
    public static String car; 
    public static final Uri APN_TABLE_URI = Uri 
      .parse("content://telephony/carriers"); 
    public static String Base_URL = "https://www.mysettings.com/"; 
    //NetworkTask task = new NetworkTask(); 
    NetworkTask tasks = new NetworkTask(); 
    InputStream stream = null; 
    private AnimationDrawable loadingAnimation; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
      int version = android.os.Build.VERSION.SDK_INT; 
      tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); 
      int networkType = tm.getNetworkType(); 
      int phoneType = tm.getPhoneType(); 
      tasks = new NetworkTask(); 
      handler = new XmlParserHandlerFinal(); 

      handler.setContext(ctx); 
      getImpVariablesForQuery(); 

      if (version < VERSION_CODES.ICE_CREAM_SANDWICH) { 

      try { 
       // updating layout initially has updating text with 1 dot in the 
       // xml 
       setContentView(R.layout.updating); 
       // This image view has the updating text to be progressively 
       // updated 
       // with dots addition 
       ImageView loading = (ImageView) findViewById(R.id.loading_empty1); 

       // Set updating button to drawable animation 
       loading.setBackgroundResource(R.drawable.updating1); 
       loadingAnimation = (AnimationDrawable) loading.getBackground(); 

       ImageView loading2 = (ImageView) findViewById(R.id.loading_empty2); 

       // Set updating button to drawable animation 
       loading2.setBackgroundResource(R.drawable.updating2); 
       loadingAnimation = (AnimationDrawable) loading2.getBackground(); 

       ImageView loading3 = (ImageView) findViewById(R.id.loading_empty3); 

       // Set updating button to drawable animation 
       loading.setBackgroundResource(R.drawable.updating3); 
       loadingAnimation = (AnimationDrawable) loading.getBackground(); 

       ImageView loading4 = (ImageView) findViewById(R.id.loading_empty4); 

       // Set updating button to drawable animation 
       loading.setBackgroundResource(R.drawable.updating4); 
       loadingAnimation = (AnimationDrawable) loading.getBackground(); 

       ImageView loading5 = (ImageView) findViewById(R.id.loading_empty5); 

       // Set updating button to drawable animation 
       loading.setBackgroundResource(R.drawable.updating5); 
       loadingAnimation = (AnimationDrawable) loading.getBackground(); 

       tasks.execute("http://datasettings.site90.net/GetPhoneSettings-ST-rsp-eng.xml"); 
       if (tasks.get() != null) { 
        stream = tasks.getInputStream(); 
        Log.v("CfA", "here"); 

       } else if (tasks.get() == null) { 
        setContentView(R.layout.error); 

        // finish(); 
        // finish(); 

       } 

       handler.getQueryResponse(stream); 

       Values = getContentValues(); 

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

      // Update APN table in separate thread 
      new TableUpdateRequestTask().execute(""); 

     } else {// ICS and later versions 

      tasks.execute("http://datasettings.site90.net/GetPhoneSettings-ST-rsp-eng.xml"); 
      System.out.println("STREAM DEBUG"); 
      System.out.println(stream); 
      try { 
       if (tasks.get() != null) { 
        stream = tasks.getInputStream(); 
        Log.v("CfA", "here"); 

       } else if (tasks.get() == null) { 
        setContentView(R.layout.error); 
       } 
      } catch (InterruptedException e1) { 
       // TODO Auto-generated catch block 
       e1.printStackTrace(); 
      } catch (ExecutionException e1) { 
       // TODO Auto-generated catch block 
       e1.printStackTrace(); 
      } 
      // startActivity(new Intent(Settings.ACTION_APN_SETTINGS)); 
      try { 

       System.out.println("STREAM DEBUG2"); 
       System.out.println(stream); 

       handler.getQueryResponse(stream); 
      // System.out.println("STREAM DEBUG"); 
       //System.out.println(stream); 
       System.out.println(nameArr); 
       System.out.println(ApnArr); 
       System.out.println(mmscArr); 
       System.out.println(mmsproxyArr); 
       System.out.println(mmsportArr); 
       System.out.println(count); 
       System.out.println(proxyArr); 

       System.out.println(portArr); 

       Values = getContentValues(); 
       showNotification(); 
      } catch (SAXException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } catch (ParserConfigurationException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 

       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } catch (IOException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 
      new TableUpdateRequestTask().execute(""); 
     } 
    } 
+0

자세한 내용을 보내십시오. 문제가있는 곳이 명확하지 않다 –

+0

그게 도움이된다면 내 logcat에서 발췌 문장을 추가했습니다. 당신이 원하는 다른 세부 정보를 알려주지 않으면 그들을 기꺼이 제공 할 것입니다.) - Amani Swann – user2665859

답변

0

당신이 스레드에서 작성되는 데이터를 사용하여 즉시 다음 스레드를 시작하고있는 것 같습니다? 그게 사실이야?

그렇다면 처리기를 만들고 스레드에서 처리기로 메시지를 보내 진행 상황 또는 스레드 완료시기를 표시해야합니다.

그래서이 코드는 모두 tasks.execute (...)로 변경되고 스레드는 핸들러에 스레드 실행이 완료되었음을 나타내는 메시지를 보냅니다. 핸들러가 메시지를 수신하면 스레드에서 작성된 정보를 사용할 수 있습니다. Here's a good article on this subject.

또한 Android에서는 System.out.println을 사용하지 마십시오. 대신 Log 클래스를 사용하십시오.

+0

I 처리기 (완전히 표시하도록 소스를 업데이트했습니다)가 잘못되었습니다. – user2665859