I'm trying to get substring from string tekst, after pressing button the app is crashing. This is code of onClick, the rest of code is fine, when im doing setText() it setting it fine but when i'm trying some kind of tekst.substring() or indexof it crashes.
public void otworz(View view) throws Exception {
new JSONTask().execute("http://www.filmweb.pl/serial/Biuro-2005-202887");
String tekst1 = new String(tekst.substring(10,20));
tView.setText(tekst1);
}
In logcat, I am getting this:
10-13 19:43:00.321 11118-11118/com.kuba.zneta E/AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.substring(int, int)' on a null object reference