I have this Android code:
package com.XXX
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.IOException;
public class DataProvider {
String baseUri;
DataProvider() {
baseUri = "http://www.XXX.de/XXX/";
}
public String requestUser(String userName) {
HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet(baseUri + "get.php?userName=" + userName);
ResponseHandler<String> handler = new BasicResponseHandler();
String result = "";
try {
result = httpclient.execute(request, handler);
} catch (ClientProtocolException e) {
result = "ClientProtocolException was thrown";
} catch (IOException e) {
result = "IOException was thrown";
}
finally {
httpclient.getConnectionManager().shutdown();
}
return result;
}
}
and in my activity
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_reload_package) {
String response = dataProvider.requestUser("BKDJSHDD-1912772-DIKDS-19172");
browser.loadDataWithBaseURL("file:///android_asset/", response, "text/html", "UTF-8", "file:///android_asset/index.html");
return true;
}
return super.onOptionsItemSelected(item);
}
Clicking the menu item causes the app to Crash. The objects browser
and dataProvider
are 100% correctly declared. I test the app on my device, because my PC is to weak to run the emulator, therefore no console output.
Any ideas?:..