Код: Выделить всё
public class VkWebViewClient extends WebViewClient {
private static final String TAG = "Vkfunc";
public String access;
public String us_id;
public String mess;
public VkWebViewClient() {
// TODO Auto-generated constructor stub
}
@Override
public void onPageFinished(WebView view, String url) {
Log.i("VkWebViewClient onPageFinished", url);
if (url.contains("oauth.vk.com/blank.html#")) {
if (url.contains("error")) {
// Error
} else {
String ahrore = url.substring(url.indexOf("#") + 1);
Log.d(TAG, ahrore);
String access_token = ahrore.substring(ahrore.indexOf("n")+2,ahrore.indexOf("&"));
access = access_token;
//String user_id = null;
Log.d(TAG, access_token);
int i = ahrore.lastIndexOf("=");
String tmpStr = ahrore.substring(i + 1, ahrore.length());
Log.d(TAG, tmpStr);
us_id = tmpStr;
Log.d(TAG, us_id);
boolean errorFlag = true;
String mess = "Hello Post";
mess = "Hello";
String urls = "https://api.vk.com/method/"+
"wall.post?"+
"uid="+ us_id+
"&message="+mess+
"&access_token="+access
;
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(urls);
try {
HttpResponse response = client.execute(request); на этой строчке падает приложение
Log.d(TAG, "Запрос");
HttpEntity entity = response.getEntity();
Log.d(TAG, "Запрос");
String responseText = EntityUtils.toString(entity);
//parse response for error code or not
// errorFlag = parseResponse(responseText);
//Log.d(Constants.DEBUG_TAG,"response text="+responseText);
}
catch(ClientProtocolException cexc){
cexc.printStackTrace();
}
catch(IOException ioex){
ioex.printStackTrace();
}
}
}
}
}