My app main method look like this:
public class MainActivity extends Activity{
ImageButton btnRegister, btnConfig, btnSurvey, btnUpload;
SQLiteDatabase profile;
TextView txtv;
TextView tv;
EditText et;
TextView txtLat;
TextView txtLong;
Spinner spinner;
List<Integer> editTextIdList = new ArrayList<Integer>();
int id = 0;
Button btnLatLng;
List<String> assetArray = new ArrayList<String>();
//Upload server
private Socket socket;
private static final int SERVERPORT = 6000;
private static final String SERVER_IP = "115.254.100.2";
//GPSTracker class
GPSTracker gps;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
isNetworkConnected();
initializer();
//Thread initialize
new Thread(new ClientThread()).start();
}
public boolean isNetworkConnected() {
final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
return activeNetwork != null && activeNetwork.getState() == NetworkInfo.State.CONNECTED;
}
It requires internet access. But without internet access it got crashed. How can I avoid crashing of application, Instaed can I give an Toast meassge ane exit the app without crash?? How can I do that?