Where does the Toast come from?
Recently I need to modify one program as to add some new features. The program is used to collect the information around the mobile and send them to a server defined by the user or store the data on the SD card. But if we don't set the server host ourselves, the app will show a toast every 5 seconds when running:localhost/127.0.0.1:5001 – Connection refused
.
Does anyone know how I can know this toast come from? Since there are some many places in the code we have a toast.show()
.
Thanks in advance!
Here is the possible snippet of code which may cause the pr开发者_StackOverflowoblem./**
* Update GPS Status
*/
public void updateGpsStatus(Context context, Handler handler) {
try {
LocationManager locationManager = (LocationManager) context
.getSystemService(Context.LOCATION_SERVICE);
this.gpsStatus = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
} catch (Exception e) {
if (handler == null) {
ComFunc.showToast(context, e.getMessage());
} else {
ComFunc.showToast(context, e.getMessage(), handler);
}
e.printStackTrace();
}
}
change all toast.show
to foo
and in foo
check for the rogue string, if its there go to your breakpoint.
Difficult to speculate since we have no idea what program you're talking about.
However, my first attempt would be to search my source code for localhost/127.0.0.1:5001 – Connection refused
and find where that is being used.
The hostname/ip may be generated, so also try searching for – Connection refused
精彩评论