0

i am trying to run a simple app but when i run on an emulator it seems like the app has stopped running during start of the app

this is the code

  public class MainActivity extends ActionBarActivity {

EditText nameTxt,ageTxt, genderTxt, nationalityTxt, icnuTxt, dobTxt, pobTxt, heightTxt, weightTxt, bloodTypeTxt, bloodPressureTxt;

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


    nameTxt = (EditText) findViewById(R.id.nameTxt);
    ageTxt = (EditText) findViewById(R.id.ageTxt);
    genderTxt = (EditText) findViewById(R.id.genderTxt);
    nationalityTxt = (EditText) findViewById(R.id.nationalityTxt);
    icnuTxt = (EditText) findViewById(R.id.icnuTxt);
    dobTxt = (EditText) findViewById(R.id.dobTxt);
    pobTxt = (EditText) findViewById(R.id.pobTxt);
    heightTxt = (EditText) findViewById(R.id.heightTxt);
    weightTxt = (EditText) findViewById(R.id.weightTxt);
    bloodTypeTxt = (EditText) findViewById(R.id.bloodTypeTxt);
    bloodPressureTxt = (EditText) findViewById(R.id.bloodPressureTxt);
    TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
    final Button addBtn = (Button) findViewById(R.id.addBtn);

    tabHost.setup();

    TabHost.TabSpec tabSpec = tabHost.newTabSpec("Patient Registration");
    tabSpec.setContent(R.id.tabPatientRegistration);
    tabSpec.setIndicator("Patient Registration");
    tabHost.addTab(tabSpec);

    tabSpec = tabHost.newTabSpec("Details List");
    tabSpec.setContent(R.id.tabDetailList);
    tabSpec.setIndicator("Details List");
    tabHost.addTab(tabSpec);


    nameTxt.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            addBtn.setEnabled(!nameTxt.getText().toString().trim().isEmpty());
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    });

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

what i got is the "Skipped 138 frames! The application may be doing too much work on its main thread.".

this as well "Process com.example.appregisterpatient (pid 1272) has died."

2 Answers2

1

is this all your code ?

The message you are seeing is important on phones but not in the emulator. The emulator is extremely slow. Nothing you are doing is resource intensive so your application should perform nominally on a device.

Have you tried it on real device ? :)

Matej Špilár
  • 2,617
  • 3
  • 15
  • 28
0

You get Skipped 138 frames because you UI thread is too busy, see this post

Community
  • 1
  • 1
betteroutthanin
  • 7,148
  • 8
  • 29
  • 48