Android 无法创建位图

Android 无法创建位图,android,google-app-engine,bitmap,http-post,Android,Google App Engine,Bitmap,Http Post,有人能告诉我为什么没有创建位图吗?如果我做错了,请检查其他代码 HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("URL"); List<NameValuePair> list = new ArrayList<NameValuePair>(); list.add(new BasicNameValuePair("username",u

有人能告诉我为什么没有创建位图吗?如果我做错了,请检查其他代码

HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("URL");

    List<NameValuePair> list = new ArrayList<NameValuePair>();
    list.add(new BasicNameValuePair("username",username));
    UrlEncodedFormEntity urlencodedformentity = new UrlEncodedFormEntity(list);

    httppost.setEntity(urlencodedformentity);
    HttpResponse response = httpclient.execute(httppost);
    InputStream is = response.getEntity().getContent();

// following Bitmap is getting null

    Bitmap bm = BitmapFactory.decodeStream(new BufferedInputStream(is));
    if(bm==null)
    {
        Toast.makeText(this,"Bitmap null", Toast.LENGTH_LONG).show();
    }
    else
    {
        img.setImageBitmap(bm);
    }
服务器端发送映像

String username = req.getParameter("username");
resp.getWriter().write(username);

try
{
byte[] image = req.getParameter("image").getBytes();

Blob profilepic = new Blob(image);

Profile profile = new Profile(username,profilepic);

pm = PMF.get().getPersistenceManager();

pm.currentTransaction().begin();

pm.makePersistent(profile);

pm.currentTransaction().commit();

resp.getWriter().write("Data stored successfully");
}
String username = req.getParameter("username");

pm = PMF.get().getPersistenceManager();
pm.currentTransaction().begin();

javax.jdo.Query query = pm.newQuery(Profile.class);
Collection<Profile> result = (Collection<Profile>) query.execute();

for (Profile result1 : result) 
{
    if(result1.getUsername().equalsIgnoreCase(username))
    {
        resp.getWriter().write(result1.getImage().toString());
        pm.currentTransaction().commit();
        break;              
    }

}
String username=req.getParameter(“用户名”);
pm=PMF.get().getPersistenceManager();
pm.currentTransaction().begin();
javax.jdo.Query Query=pm.newQuery(Profile.class);
集合结果=(集合)query.execute();
用于(配置文件结果1:结果)
{
if(result1.getUsername().equalsIgnoreCase(用户名))
{
resp.getWriter().write(result1.getImage().toString());
pm.currentTransaction().commit();
打破
}
}

应使用asynctask进行网络相关操作。你用过同样的方法吗?我也试过异步任务,但我想问题出在其他方面
String username = req.getParameter("username");

pm = PMF.get().getPersistenceManager();
pm.currentTransaction().begin();

javax.jdo.Query query = pm.newQuery(Profile.class);
Collection<Profile> result = (Collection<Profile>) query.execute();

for (Profile result1 : result) 
{
    if(result1.getUsername().equalsIgnoreCase(username))
    {
        resp.getWriter().write(result1.getImage().toString());
        pm.currentTransaction().commit();
        break;              
    }

}