in Education by
I am using simple thread to execute the httpGet to server when a button is clicked, but I get this after execution. Button b_back = (Button) findViewById(R.id.bback); b_back.setOnClickListener(this); Button b_sign_up = (Button) findViewById(R.id.signup_button); b_sign_up.setOnClickListener(this); @Override public void onClick(View arg0) { // TODO Auto-generated method stub switch (arg0.getId()) { case R.id.bback: Intent i = new Intent(this, MainSwitch.class); finish(); startActivity(i); break; // More buttons go here (if any) ... case R.id.signup_button: if(username.getText().toString().equalsIgnoreCase("") || password.getText().toString().equalsIgnoreCase("") || email.getText().toString().equalsIgnoreCase("")) { AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setMessage("Please fill in all the gaps!"); dialog.show(); } else { //****** Call method that sends the information to server. Thread background = new Thread (new Runnable() { public void run() { // Call the time consuming method handler.sendEmptyMessage(0); } }); background.start(); } } } private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { Toast.makeText(getApplicationContext(), "Done thread", Toast.LENGTH_SHORT).show(); } }; JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The errorline you get: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() is typically linked to problems where you try to do stuff to UI-elements on a non-UI-thread. I suppose that by stating // Call the time consuming method you have left out some of your code. The fact that this time consuming method runs on a regulare Thread means it cannot interact with UI-elements. If you post more code (and also which specify the line where the error occurs) we can probably provide more info on how to solve it.

Related questions

0 votes
    Which of these classes is not included in java.lang? (a) Byte (b) Integer (c) Array (d) Class ... java programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    JavaScript has to called inside ________ tags 1. Either in body or head 2. head 3. body 4. script...
asked Feb 23, 2021 by JackTerrance
+1 vote
    JavaScript has to called inside ________ tags a)head b)body c)script...
asked Oct 8, 2020 in Technology by JackTerrance
0 votes
    This question already has answers here: How to deal with "java.lang.OutOfMemoryError: Java heap space" error ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    I get an java.lang.OutOfMemoryError: GC overhead limit exceeded when run gradle on Android 1.4 ... ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    When installing PDFBox with Maven, it places the libraries in the ~/.m2/repository directory. My program ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I have a 2 column (1 int and 1 double) dataframe "fit_comparison", of predicted values and linear ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    what configuration needs to be tweaked, and where does it live, in order to increase the maximum allowed ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    what configuration needs to be tweaked, and where does it live, in order to increase the maximum allowed ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I am trying to deploy our eRCP (embedded Rich Client Platform) application on a Windows CE5 Professional ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I am trying to deploy our eRCP (embedded Rich Client Platform) application on a Windows CE5 Professional ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
...