我在logcat中收到此消息,在设备上运行app时,我使用了活动中的片段我跳转到此活动,下面是我此特定活动的代码。 我不明白为什么我收到这条消息,因为我已经在背景上运行了所有内容。我也使用DrawerLayout进行导航,并使用片段,我以前的活动也是这样做的,这可能是跳过帧的原因吗?
private class GetProjectInfo extends AsyncTask<String,String, String>
{
@Override
protected String doInBackground(String... params)
{
try
{
JSONObject jObj = new JSONObject();
jObj.put("project_id",prefs.getString("project_id",""));
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(Constants.TATA_PROJECTS_URL);
StringEntity se = new StringEntity(jObj.toString());
httpPost.setEntity(se);
se.setContentType("application/json; charset=UTF-8");
se.setContentEncoding("UTF-8");
httpPost.setEntity(se);
httpPost.setHeader("Content-type", "application/json; charset=UTF-8");
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
result = EntityUtils.toString(httpEntity, HTTP.UTF_8);
Constants.project_data = result;
}
catch(Exception e)
{
e.printStackTrace();
}
return result;
}
@Override
protected void onPostExecute(String s)
{
super.onPostExecute(s);
if(s == null || s.equals(""))
{
pDialog.dismiss();
}
else
{
try
{
JSONObject resObj = new JSONObject(s);
JSONObject dataObj = resObj.getJSONObject("abc");
String project_id = dataObj.getString("project_id");
String project_name = dataObj.getString("project_name");
String project_location = dataObj.getString("project_location");
String project_img = dataObj.getString("project_img_url");
String project_background = dataObj.getString("project_background");
String project_tagline = dataObj.getString("project_tagline");
String project_text = dataObj.getString("project_text");
HashMap<String,String> hm = new HashMap<String,String>();
hm.put("project_id",project_id);
hm.put("project_name",project_name);
hm.put("project_location",project_location);
hm.put("project_img",project_img);
hm.put("project_background",project_background);
hm.put("project_tagline",project_tagline);
hm.put("project_text",project_text);
pro_info_list.add(hm);
//set texts
if(!project_tagline.equals("") && !project_text.equals(""))
{
pro_tag_line.setText(project_tagline);
pro_text.setText(project_text);
}
else if(project_tagline.equals("") && !project_text.equals(""))
{
pro_tag_line.setVisibility(View.GONE);
pro_text.setText(project_text);
}
else if(!project_tagline.equals("") && project_text.equals(""))
{
pro_tag_line.setText(project_tagline);
pro_text.setVisibility(View.GONE);
}
else
{
pro_tag_line.setVisibility(View.GONE);
pro_text.setVisibility(View.GONE);
}
JSONArray project_menu = dataObj.getJSONArray("project_menu_data");
for(int i = 0; i < project_menu.length(); i++)
{
JSONObject menuObj = project_menu.getJSONObject(i);
String menu_name = menuObj.getString("menu_data_name");
String menu_img = menuObj.getString("menu_data_img_url");
String menu_id = menuObj.getString("project_menu_id");
HashMap<String, String> hm1 = new HashMap<String, String>();
hm1.put("menu_id",menu_id);
hm1.put("menu_name",menu_name);
hm1.put("menu_img",menu_img);
pro_menu_list.add(hm1);
// creating buttons for menu options
MyButton menulayout = new MyButton(ProjectActivity.this);
LinearLayout.LayoutParams lay_params = new LinearLayout.LayoutParams
(LinearLayout.LayoutParams.MATCH_PARENT, (int)getResources().getDimension(R.dimen.menu_btn_ht));
lay_params.setMargins((int)getResources().getDimension(R.dimen.menu_btn_mg_lft_rt),
(int) getResources().getDimension(R.dimen.menu_btn_mg_top_bottom),
(int)getResources().getDimension(R.dimen.menu_btn_mg_lft_rt),
(int) getResources().getDimension(R.dimen.menu_btn_mg_top_bottom));
lay_params.gravity = Gravity.CENTER_HORIZONTAL;
menulayout.setLayoutParams(lay_params);
menulayout.setGravity(Gravity.CENTER_VERTICAL);
menulayout.setText(menu_name);
if(prefs.getInt("screen_ht",0) == 1776 && prefs.getInt("screen_wd",0) == 1080) // for nexus 5 and sony xperia z
{
menulayout.setTextSize(14);
}
else
{
menulayout.setTextSize((int)getResources().getDimension(R.dimen.menu_btn_txt_size));
}
menulayout.setTextColor(getResources().getColor(R.color.blue));
menulayout.setBackgroundResource(R.drawable.custom_btn_layout1);
//menulayout.setTag(menu_id);
menulayout.setTag(i);
menulayout.setOnClickListener(menuClickListener);
project_menu_lay.addView(menulayout);
}
if(!project_img.equals(""))
{
new DownloadProjectImage(projectImage).execute(project_img);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
答案 0 :(得分:0)
您需要从this link中的主要活动调用您在代码GetProjectInfo中显示的类。
示例:
new GetProjectInfo().execute(string1, string2, string3);
答案 1 :(得分:0)
当您看到此消息时,是否附加了调试器?如果是,你是否也在没有调试器的情况下看到它?如果不是,那么它很可能是一个导致你的应用程序变慢的调试器。
特别是,如果你在调试器中挂断断点,你会看到这样的消息,跳过的帧数更多(取决于你在断点上等待多长时间)。