小编Eth*_*err的帖子

HttpResponse使用android问题:执行总是导致异常?

我一直在研究一个Android项目,我想要一些API来获取信息.看起来这应该是非常基本的!

这是我的代码的一般要点:

private InputStream retrieveStream2(String url)
{
    DefaultHttpClient client = new DefaultHttpClient();

    HttpGet getRequest = new HttpGet(url);
    System.out.println("getRequest == " + getRequest);
    try {


        HttpResponse getResponse = client.execute(getRequest);//here is teh problem
        final int statusCode = getResponse.getStatusLine().getStatusCode();


        if (statusCode != HttpStatus.SC_OK)
        {
            Log.w(getClass().getSimpleName(),
                    "Error " + statusCode + " for URL " + url);
            return null;
        }

        HttpEntity getResponseEntity = getResponse.getEntity();
        return getResponseEntity.getContent();

    }
    catch (Exception e)
    {
        getRequest.abort();
        Log.w(getClass().getSimpleName(), "Error for URL, YO " + url, e);
    }
    return null; …
Run Code Online (Sandbox Code Playgroud)

java android httpresponse android-asynctask

10
推荐指数
3
解决办法
3万
查看次数

让三星galaxy nexus adb工作

我正在尝试在我全新的Galaxy Nexus上调试我的应用程序.
我做了以下事情:

驱动程序:安装Galaxy驱动程序安装了Galaxy Nexus驱动程序(可以在设备管理器中看到这个,Galaxy在"其他设备"下,Galaxy Nexus在"便携设备"下).

我也在电话中进入了settings-> developer选项并打开了USB Debugging.我还在我的应用程序清单中添加了debug-mod选项.

现在我已经在命令提示符下导航到目录.. ...\Android\android.sdk\platform-tools \我现在尝试执行命令

adb设备.

结果是:"附加设备列表"

然后是一个空白行.

我做错了什么?

android adb galaxy-nexus

5
推荐指数
2
解决办法
8912
查看次数