在我的应用程序中,我有一些按钮,当我点击Them应用程序从网络获取数据并显示到listView时。 问题是,有时当我点击按钮屏幕时会冻结并显示空白的黑屏。
这是logcat的错误:
09-20 11:17:12.437:E / InputDispatcher(469):channel' a6941398 com.employment.app.find_work.recruitment / com.employment.app.find_work.recruitment.ActivityFirst(server)& #39; 〜频道无法恢复,将被处理掉!
09-20 11:17:12.449:E / InputDispatcher(469):channel' a6aa7d08正在加载请等待(服务器)' 〜频道无法恢复,将被处理掉!
public class ActivityFirst extends Activity {
public static Handler handler = new Handler();
public static ProgressDialog progress;
private static final int TIME_INTERVAL = 2000; // # milliseconds, desired time passed between two back presses.
private long mBackPressed;
ImageView img_agahi_estekhdami;
ImageView img_akhbar_estekhdami;
ImageView img_akhabar_eghtesadi;
ImageView img_karafarini;
ImageView img_setting;
ImageView img_about;
public myAsynctask myAsynctask;
public myAsynctask2 myAsynctask2;
public myAsynctask3 myAsynctask3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
boolean skipWelcome = G.preferences.getBoolean("SKIP_WELCOME", false);
if ( !skipWelcome)
{
Intent intent = new Intent(ActivityFirst.this, Welcome.class);
startActivity(intent);
SharedPreferences.Editor editor = G.preferences.edit();
editor.putBoolean("SKIP_WELCOME", true);
editor.commit();
}
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
img_agahi_estekhdami = (ImageView) findViewById(R.id.img_agahi_estekhdami);
img_akhbar_estekhdami = (ImageView) findViewById(R.id.img_akhbar_estekhdami);
img_akhabar_eghtesadi = (ImageView) findViewById(R.id.img_akhabar_eghtesadi);
img_karafarini = (ImageView) findViewById(R.id.img_karafarini);
img_setting = (ImageView) findViewById(R.id.img_setting);
img_about = (ImageView) findViewById(R.id.img_about);
try
{
img_agahi_estekhdami.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent3 = new Intent(ActivityFirst.this, ServerChoise.class);
startActivity(intent3);
}
});
img_akhbar_estekhdami.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
myAsynctask = new myAsynctask();
if ( !myAsynctask.isCancelled())
{
myAsynctask.execute();
}
}
});
img_akhabar_eghtesadi.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
myAsynctask2 = new myAsynctask2();
if ( !myAsynctask2.isCancelled())
{
myAsynctask2.execute();
}
}
});
img_karafarini.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
myAsynctask3 = new myAsynctask3();
if ( !myAsynctask3.isCancelled())
{
myAsynctask3.execute();
}
}
});
img_setting.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(ActivityFirst.this, Setting.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
}
});
img_about.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(ActivityFirst.this, About.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
}
});
}
catch (Exception e)
{
Toast.makeText(G.context, "Error 103", Toast.LENGTH_LONG).show();
}
}
@Override
public void onBackPressed()
{
if (mBackPressed + TIME_INTERVAL > System.currentTimeMillis())
{
super.onBackPressed();
android.os.Process.killProcess(android.os.Process.myPid());
return;
}
else {
Toast.makeText(getBaseContext(), "Press back key to Exit", Toast.LENGTH_SHORT).show();
}
mBackPressed = System.currentTimeMillis();
}
public void showLoadingDialog() {
progress = new ProgressDialog(ActivityFirst.this);
progress.setTitle("Loading please Wait");
progress.setMessage("Loading");
progress.show();
progress.setCancelable(true);
}
//---------------------------------------------------------------
public class myAsynctask extends AsyncTask<Void, Void, Void>
{
@Override
protected void onPreExecute() {
super.onPreExecute();
showLoadingDialog();
}
@Override
protected Void doInBackground(Void... params) {
Intent intent = new Intent(ActivityFirst.this, RecruitmentActivity.class);
intent.putExtra("INPUT", "http://www.eghtesadonline.com/fa/rss/relatedeconomy");
startActivity(intent);
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
progress.dismiss();
}
}
//-----------------------------------------------------------------
public class myAsynctask2 extends AsyncTask<Void, Void, Void>
{
@Override
protected void onPreExecute() {
super.onPreExecute();
showLoadingDialog();
}
@Override
protected Void doInBackground(Void... params) {
Intent intent = new Intent(ActivityFirst.this, RecruitmentActivity.class);
intent.putExtra("INPUT", "http://www.eghtesadonline.com/fa/rss/economy");
startActivity(intent);
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
progress.dismiss();
}
}
//--------------------------------------------------------------------
public class myAsynctask3 extends AsyncTask<Void, Void, Void>
{
@Override
protected void onPreExecute() {
super.onPreExecute();
showLoadingDialog();
}
@Override
protected Void doInBackground(Void... params) {
Intent intent = new Intent(ActivityFirst.this, RecruitmentActivity.class);
intent.putExtra("INPUT", "http://www.eghtesadonline.com/fa/rss/management");
startActivity(intent);
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
progress.dismiss();
}
}