There are four buttons in the user interface of my application, of which three buttons (when pressed) extract the image from mysql db and display it on the Android phone. The fourth task of the button is to get text from db.
if any of the buttons that extract the image first clicked the image, and then if the button that extracts the image is pressed, text is displayed.
But when the button that extracts the text is pressed first, even before the button that displays the image is pressed, the power of the application closes!
the code for the onClick activity of the button that retrieves the text is as follows
b.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { Toast.LENGTH_SHORT).show(); try { data.put("id",id); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String url="http://10.0.2.2:8080/finder/review/listA"; try { img.setImageBitmap(null); json =HTTPPoster.doPost(url, data); Toast.makeText(getBaseContext(),json.toString(), Toast.LENGTH_SHORT).show(); titles=json.getJSONObject("titles"); Toast.makeText(getBaseContext(), titles.toString(), Toast.LENGTH_SHORT).show(); msgs=json.getJSONObject("msgs"); names=json.getJSONObject("names"); String one=titles.getString("0"); Toast.makeText(getBaseContext(), one.toString(),Toast.LENGTH_LONG).show(); t.setText("\nReviews \n"); String content=""; for(int i=0;i<3;i++) { String msg=msgs.getString(i+""); name=names.getString(i+""); String title=titles.getString(i+""); content=t.getText()+("\n Name"+name+"\n Title: "+title+"\n Msg:"+msg); t.setText(content); Toast.makeText(getBaseContext(),"Name:"+name+"\n Title: "+title+"\n Message"+msg,Toast.LENGTH_SHORT).show(); } // t.setText() } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } });
logcat
06-07 00:25:29.923: INFO/Process(234): Sending signal. PID: 234 SIG: 9 06-07 00:25:30.042: INFO/WindowManager(58): WIN DEATH: Window{44e66ef0 com.lpss/com.lpss.MyList paused=false} 06-07 00:25:30.053: INFO/WindowManager(58): WIN DEATH: Window{44d72da0 com.lpss/com.lpss.lpss paused=false} 06-07 00:25:30.053: INFO/ActivityManager(58): Process com.lpss (pid 234) has died. 06-07 00:25:30.062: WARN/GpsLocationProvider(58): Unneeded remove listener for uid 1000 06-07 00:25:30.062: DEBUG/GpsLocationProvider(58): stopNavigating 06-07 00:25:30.062: INFO/WindowManager(58): WIN DEATH: Window{44dedb10 Toast paused=false} 06-07 00:25:30.091: WARN/ActivityManager(58): Scheduling restart of crashed service com.lpss/.NotifyService in 5000ms 06-07 00:25:30.103: INFO/WindowManager(58): WIN DEATH: Window{44dd9490 com.lpss/com.lpss.Contents paused=false} 06-07 00:25:30.244: INFO/ActivityManager(58): Start proc com.lpss for activity com.lpss/.MyList: pid=248 uid=10030 gids={3003, 1015} 06-07 00:25:30.244: ERROR/ActivityThread(58): Failed to find provider info for android.server.checkin 06-07 00:25:30.244: WARN/Checkin(58): Can't log event SYSTEM_SERVICE_LOOPING: java.lang.IllegalArgumentException: Unknown URL content:
which retrieves the image
b3.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { try { data.put("name",name); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } String url="http://10.0.2.2:8080/finder/place/ph?id="+id; // json =HTTPPoster.doPost(url, data); downloadImage(url); // Toast.makeText(this,json.toString() , Toast.LENGTH_SHORT).show(); } }); b4.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { t.setText(""); try { data.put("name",name); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } String url="http://10.0.2.2:8080/finder/place/map?id="+id; // json =HTTPPoster.doPost(url, data); downloadImage(url); // Toast.makeText(this,json.toString() , Toast.LENGTH_SHORT).show(); } });