1

I am developing and Android application with a Facebook log in, and I keep having the following warning on logcat : "Choreographer﹕ Skipped xx frames! The application may be doing too much work on its main thread.". First I thought maybe I am doing too much operations on the main thread of the activity, but then I tried to comment parts from the code that I thought are heavy operations until I commented everything and I left almost nothing running on the main thread. But I'm still having the same warning. Here is my actual code now (Not including the commented parts) :

public class Login extends Activity implements OnClickListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_login, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

@Override
public void onBackPressed() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Are you sure you want to exit?")
            .setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Login.this.finish();
                }
            })
            .setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

}

AymanKun
  • 241
  • 1
  • 4
  • 20
  • possible duplicate of [The application may be doing too much work on its main thread](http://stackoverflow.com/questions/14678593/the-application-may-be-doing-too-much-work-on-its-main-thread) – Psypher Feb 19 '15 at 20:23
  • I found out that the problem was with the virtual device I was using not with my code. I tried it on a device using Android 4.2.2 aPI 17 and it's running super fast. Thank you anyway. – AymanKun Feb 19 '15 at 20:32

0 Answers0