运行时出错

时间:2014-02-23 07:15:45

标签: java android

我正在开发一个Android应用程序,它从服务器获取数据,但突然停止从服务器获取数据,我在我的日志猫中收到这两个错误。从GradienCache获取MAX_TEXTURE_SIZE并从MAX_TEXTURE_SIZE获取Caches::initConstraints()。任何人都可以告诉我这是什么错误,我该如何改进呢?

public class PropertyListActivity extends BaseActivity {

    private ListView listView;
    private PropertyListAdapter adapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_property_list);

        try {
            if(PropertyUtil.CheckInternetConnection()){
                makeAsyncUpdate();
            } else {
                Toast.makeText(PropertyListActivity.this, "No Internet connection", Toast.LENGTH_SHORT).show();
                this.finish();
            }
        } catch (Exception e) {
            e.printStackTrace();
            PropertyUtil.hideProgressDialog(PropertyListActivity.this);
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.list_activity_actions, menu);

        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(item.getItemId()==R.id.action_list_refresh){
            if(PropertyUtil.CheckInternetConnection()) {
                makeAsyncUpdate();
            } else {
                Toast.makeText(PropertyListActivity.this, "No Internet connection", Toast.LENGTH_SHORT).show();
            }

            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    private void makeAsyncUpdate() {
        StringEntity params = null;
        try {
            params = getPostParams();
        } catch (Exception e) {
            e.printStackTrace();
        }

        if(params==null) {
            Toast.makeText(PropertyListActivity.this, "Failed to load, Please Retry!!", Toast.LENGTH_SHORT).show();
            this.finish();
        } else {
            asyncHttpClient.post(PropertyListActivity.this, BASE_INFO_URL, params, "application/json",  new AsyncHttpResponseHandler() {

                @Override
                public void onStart() {
                    super.onStart();
                    PropertyUtil.showProgressDialog(PropertyListActivity.this, "Loading properties...");
                }

                @Override
                public void onFinish() {
                    super.onFinish();
                    PropertyUtil.hideProgressDialog(PropertyListActivity.this);
                }

                @Override
                public void onSuccess(String response) {
                    super.onSuccess(response);
                    Log.i("AsyncHttpClient", response);

                    setUpPropertyListingView(response);
                }

                @Override
                public void onFailure(Throwable arg0, String arg1) {
                    super.onFailure(arg0, arg1);
                    Log.i("AsyncHttpClient", "Failed: " + arg1);
                }
            });
        }
    }

    private StringEntity getPostParams() throws Exception {
        JSONObject jsonParams = new JSONObject();
        jsonParams.put("action", "fetch");

        return new StringEntity(jsonParams.toString());
    }

    private void setUpPropertyListingView(String jsonResponse) {
        final BaseInfo[] basicInfoList = gson.fromJson(jsonResponse, BaseInfo[].class);

        if(listView==null) {
            listView = (ListView) findViewById(R.id.listViewProperty);
        }

        if(adapter!=null) {
            adapter.setData(Arrays.asList(basicInfoList));
        } else {
            adapter = new PropertyListAdapter(PropertyListActivity.this, R.layout.activity_property_list, Arrays.asList(basicInfoList));
            listView.setAdapter(adapter);

            listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Intent i = new Intent(PropertyListActivity.this, PropertyDetailsActivity.class);
                    i.putExtra(PropertyConstants.PROPERTY_BASE_INFO_KEY, adapter.getItem(position).getBaseInfoKey());

                    startActivity(i);
                }
            });
        }
    }
}

这是我的日志猫

02-23 07:41:51.575: D/dalvikvm(2101): GC_FOR_ALLOC freed 50K, 9% free 2867K/3144K, paused 34ms, total 36ms  
02-23 07:41:51.619: I/dalvikvm-heap(2101): Grow heap (frag case) to 3.932MB for 960012-byte allocation  
02-23 07:41:51.695: D/dalvikvm(2101): GC_FOR_ALLOC freed 2K, 7% free 3802K/4084K, paused 76ms, total 76ms  
02-23 07:41:51.775: D/main(2101): inside main  
02-23 07:41:52.063: D/libEGL(2101): loaded /system/lib/egl/libEGL_genymotion.so  
02-23 07:41:52.095: D/(2101): HostConnection::get() New Host Connection established 0xb7ecf2d8, tid 2101
02-23 07:41:52.111: D/libEGL(2101): loaded /system/lib/egl/libGLESv1_CM_genymotion.so
02-23 07:41:52.115: D/libEGL(2101): loaded /system/lib/egl/libGLESv2_genymotion.so
02-23 07:41:52.243: W/EGL_genymotion(2101): eglSurfaceAttrib not implemented
02-23 07:41:52.243: E/OpenGLRenderer(2101): Getting MAX_TEXTURE_SIZE from GradienCache
02-23 07:41:52.267: E/OpenGLRenderer(2101): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
02-23 07:41:52.267: D/OpenGLRenderer(2101): Enabling debug mode 0
02-23 07:41:54.319: W/EGL_genymotion(2101): eglSurfaceAttrib not implemented

0 个答案:

没有答案