2012-04-10 6 views
1

Google 캘린더에서 정보를 가져 오는 응용 프로그램이 PHP API에서 가져 오는 경우 문제는 응용 프로그램이 에뮬레이터에서 작동하지만 문제가 발생하면 시도하는 것입니다. 내 휴대 전화에 정보가없는 일반 검정색 화면 만 사용하십시오. 그것은 연결 문제 (첫 번째 생각과 달리) 인 것 같습니다. 에뮬레이터의 Android 버전은 2.3.3이며 내 휴대 전화와 동일합니다. Android 앱이 에뮬레이터에서 작동하지만 전화가 연결되지 않은 경우 (연결 문제)

내 코드입니다 :

public class AgendaActivity extends Activity { 
    /** Called when the activity is first created. */ 
    public static final String CAL= "http://192.168.1.58/calendar.php"; 
    ListView vue; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    vue = (ListView) findViewById(R.id.listView1); 
     List<HashMap<String, String>> liste = new ArrayList<HashMap<String,String>>();  
     HashMap<String, String> element; 
    String result = getServerData(CAL); 
    String[] chaine = result.split(";"); 
    for(int i=1;i<chaine.length-1;i++) 
    { 
       String[] event = chaine[i].split(":"); 
       element = new HashMap<String, String>(); 
       element.put("titre", event[1]); 
       element.put("date",event[3]+":"+event[4]); 
       liste.add(element); 
    } 
     ListAdapter adapter = new SimpleAdapter(this, 
      liste, 
      android.R.layout.simple_list_item_2, 
      new String[] {"titre", "date"}, 
      new int[] {android.R.id.text1, android.R.id.text2 }); 
     vue.setAdapter(adapter);  
} 
private String getServerData(String returnString) {  
    InputStream is = null; 
    String result = ""; 
    File file = new File("sdcard/event.txt"); 
    FileWriter fw; 
    FileReader fr; 
    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); 
    nameValuePairs.add(new BasicNameValuePair("contact","")); 
    HttpResponse response=null; 
    try{ 
     HttpClient httpclient = new DefaultHttpClient(); 
     HttpPost httppost = new HttpPost(returnString); 
     httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 
     response = httpclient.execute(httppost); 
     HttpEntity entity = response.getEntity(); 
     is = entity.getContent(); 
    }catch(Exception e){ 
     Log.e("log_tag", "Error in http connection " + e.toString()); 
     String str = ""; 
     int i = 0; 
     try { 
      fr =new FileReader(file); 
      while((i = fr.read()) != -1) 
       str += (char)i; 
     } catch (IOException e1) { 
      // TODO Auto-generated catch block 
      e1.printStackTrace(); 
     } 
     returnString=str; 
     return returnString;  
    } 
    try{ 
     BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8); 
     StringBuilder sb = new StringBuilder(); 
     String line = null; 
     while ((line = reader.readLine()) != null) { 
      sb.append(line + "\n"); 
     } 
     is.close(); 
     result=sb.toString(); 
    }catch(Exception e){ 
     Log.e("log_tag", "Error converting result " + e.toString()); 
    } 
    try{ 
     JSONArray jArray = new JSONArray(result); 
     for(int i=0;i<jArray.length();i++) 
     { 
      JSONObject json_data = jArray.getJSONObject(i); 
      returnString = ""+ json_data; 
     } 
     }catch(JSONException e) 
    { 
     returnString=e.toString(); 
    } 
    try { 
      fw = new FileWriter(file); 
     fw.write(returnString); 
     fw.close(); 
    } catch (FileNotFoundException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    return returnString; }  
} 

시뮬레이터의 응용 프로그램은 내가 응용 프로그램을 실행할 때 오류 섹션에서 로그 캣에 도착, 잘 작동하지만 :

04-10 15:03:56.493: E/Zygote(33): setreuid() failed. errno: 2 
04-10 15:04:09.523: E/Zygote(33): setreuid() failed. errno: 17 
04-10 15:04:12.363: E/BatteryService(72): usbOnlinePath not found 
04-10 15:04:12.363: E/BatteryService(72): batteryVoltagePath not found 
04-10 15:04:12.363: E/BatteryService(72): batteryTemperaturePath not found 
04-10 15:04:12.393: E/SurfaceFlinger(72): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake 
04-10 15:04:12.723: E/SensorService(72): couldn't open device for module sensors (Invalid argument) 
04-10 15:04:20.463: E/EventHub(72): could not get driver version for /dev/input/mouse0, Not a typewriter 
04-10 15:04:20.463: E/EventHub(72): could not get driver version for /dev/input/mice, Not a typewriter 
04-10 15:04:20.493: E/System(72): Failure starting core service 
04-10 15:04:20.493: E/System(72): java.lang.SecurityException 
04-10 15:04:20.493: E/System(72): at android.os.BinderProxy.transact(Native Method) 
04-10 15:04:20.493: E/System(72): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146) 
04-10 15:04:20.493: E/System(72): at android.os.ServiceManager.addService(ServiceManager.java:72) 
04-10 15:04:20.493: E/System(72): at com.android.server.ServerThread.run(SystemServer.java:206) 
04-10 15:04:21.153: E/SoundPool(72): error loading /system/media/audio/ui/Effect_Tick.ogg 
04-10 15:04:21.153: E/SoundPool(72): error loading /system/media/audio/ui/KeypressStandard.ogg 
04-10 15:04:21.163: E/SoundPool(72): error loading /system/media/audio/ui/KeypressSpacebar.ogg 
04-10 15:04:21.163: E/SoundPool(72): error loading /system/media/audio/ui/KeypressDelete.ogg 
04-10 15:04:21.163: E/SoundPool(72): error loading /system/media/audio/ui/KeypressReturn.ogg 
04-10 15:04:21.245: E/UsbObserver(72): java.lang.NullPointerException 
04-10 15:04:21.245: E/UsbObserver(72): at com.android.server.UsbObserver.init(UsbObserver.java:131) 
04-10 15:04:21.245: E/UsbObserver(72): at com.android.server.UsbObserver.<init>(UsbObserver.java:65) 
04-10 15:04:21.245: E/UsbObserver(72): at com.android.server.ServerThread.run(SystemServer.java:402) 
04-10 15:04:22.623: E/ThrottleService(72): Could not open GPS configuration file /etc/gps.conf 
04-10 15:04:26.083: E/logwrapper(173): executing /system/bin/tc failed: No such file or directory 
04-10 15:04:26.123: E/logwrapper(174): executing /system/bin/tc failed: No such file or directory 
04-10 15:04:26.239: E/logwrapper(175): executing /system/bin/tc failed: No such file or directory 
04-10 15:17:37.467: E/InputDispatcher(72): channel '407739a0 com.android.agenda/com.android.agenda.AgendaActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8 
04-10 15:17:37.467: E/InputDispatcher(72): channel '407739a0 com.android.agenda/com.android.agenda.AgendaActivity (server)' ~ Channel is unrecoverably broken and will be disposed! 

아이디어가 있으십니까?

답변

1

마침내 문제가 발생한 부분을 발견했습니다. 나는 oustide에서 연결을 허용하는 나의 xampp의 설정을 변경하지 않았다. 나는 로컬에서만 작업하고 있었다.

+0

안녕하세요, axmpp 설정을 변경하는 방법과 변경 사항에 대해 자세히 설명해 주실 수 있습니까? 나는 또한 나는 똑같은 문제에 직면하고 있다고 생각한다. –

+0

잘 내 문제는 마지막 부분 (새로운 보안 개념)의 httpd-xamp.conf에서 모든 실행 파일을 거부했기 때문에 로컬에서 실행이 가능하여 무엇을 허용하고 싶은지 변경해야한다는 것입니다. – ach83

관련 문제