I am unable to find the error in my android application. I have read guides on how to read logcat errors but the problem with my error is that it is not from my classes. Could someone give me some idea on how I could debug this?
I have a two spinners in my layout. One of which has an string array fixed for its list of items inside. The other spinner's items are generated dynamically with some code. The program actually runs fine on the emulator. But when I run on my device, a toggle button which doesnt uses the spinner crashes the application. If there is any more detail or information that I need to share to debug, do let me know.
Sorry I did post the logcat but the image disappeared. The complete logcat is below now.
And here is the toggle button which crashed the application when pressed.
public void onToggleClicked(View view) { Context context = getApplicationContext();
if (checkConnectivity()) {
// Is the toggle on?
boolean on = tglbtn.isChecked();
if (on) {
startRepeatingTask();
} else {
stopRepeatingTask();
}
}
else {
Toast.makeText(context, "Please check your internet connection.", Toast.LENGTH_LONG).show();
}
}
These are the two methods....
Runnable mStatusChecker = new Runnable() {
@Override
public void run() {
//updateStatus(); //this function can change value of mInterval.
new updateBuses().execute();
mHandler.postDelayed(mStatusChecker, mInterval);
}
};
void startRepeatingTask() {
mStatusChecker.run();
}
void stopRepeatingTask() {
mHandler.removeCallbacks(mStatusChecker);
}
The updateBuses class is an Asynctask which has nothing to do with my spinners. This is the method which populates my spinner.
private void plotBuses(ArrayList<MyMarker> markers) {
Log.d("Checking Array", mMyMarkersArray.toString());
if(markers.size() > 0)
{
for (MyMarker myMarker : markers)
{
// Create bus marker with custom icon and other options
Log.d("plotting", myMarker.getmLabel());
MarkerOptions markerOption = new MarkerOptions().position(new LatLng(myMarker.getmLatitude(), myMarker.getmLongitude()));
markerOption.title(myMarker.getmLabel());
markerOption.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_bus));
Marker currentMarker = map.addMarker(markerOption);
mMarkersHashMap.put(currentMarker, myMarker);
}
Log.d("check hashmap:", mMarkersHashMap.toString());
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
(this, android.R.layout.simple_spinner_item,spinnerList);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(dataAdapter);
}
}
The spinnerList is not null because my spinner populates with the items inside my spinner.