public class Activity_Login extends Activity { / / User account private AutoCompleteTextView userAccount; / / User password private EditText userPwd; / / Login button, the button to retrieve the password, register the login button private Button btnLogining, login_as_tourists, btnToRegister;
@ Override public void onClick (View arg0) { / / TODO Auto-generated method stub Intent intent = new Intent (); intent.setClass (Activity_Login.this, ActivityBIL.class); startActivity (intent); finish (); } });
/ / Add the login button listener event btnLogining.setOnClickListener (new OnClickListener () { @ Override public void onClick (View v) { / / Get user input account int account = Integer . ParseInt (userAccount.getText () toString ().); / / Get user input password String password = userPwd.getText () toString ();. / / Call the login method login (account, password); } });
btnToRegister.setOnClickListener (new OnClickListener () {
@ Override public void onClick (View arg0) { / / TODO Auto-generated method stub Intent intent = new Intent (); intent.setClass (Activity_Login.this, ActivitySignUp.class); startActivity (intent); finish (); } }); } / ** * Login method * This method is used to enter a user ID and password will be sent to the server, and the server returns data processing * @ Param account account * @ Param password Password * / protected void login (int account, String password) { boolean b = false; Entity / / Create a user for sending data to the server, the storageUserOutputEntity user = new UserOutputEntity (); SocketHandle userlogin = new SocketHandle (); user = userlogin.loginHandle (account, password); / / Call the service method to send data to the server, the server returns true if said successful landing, false representation Login failed if (user! = null) { b = true; } if (b) {/ / if successful landing try {
} Catch (Exception e) { e.printStackTrace (); } Intent intent = new Intent (this, ActivityMore.class); / / New a Bundle object and to pass data into Bundle bundle = new Bundle (); bundle.putInt ("account", account); bundle.putString ("password", password); / / Assign the bundle object to Intent intent.putExtras (bundle); / / Open Jump startActivity (intent); } Else {/ / Login failed, by Toast to the user login failure / / Toast.makeText (this, "Login failed, does not tell you why ...", Toast.LENGTH_LONG) show ();. } } }
Reply: The landlord did not print the error log posted ah? ? Click the login button guess it should be given, right? The login function into the thread execution.
/ / add event listeners login button btnLogining.setOnClickListener (new OnClickListener () { @ Override public void onClick (View v) { / / Get user input account final int account = Integer . ParseInt (userAccount.getText () toString ().); / / Get user input password final String password = userPwd.getText () toString ();. / / Call the login method new Thread () { public void run () { login (account, password); } .} Start ();
} });
Reply: The main thread properly properly networked database queries do not perform read and write large files Reply: Will be What does it mean to die. . . How to solve said. . . Reply:
12-16 09:59:16.092: D / dalvikvm (1099): GC_FOR_ALLOC freed 35K, 4% free 2808K/2912K, paused 40ms, total 41ms 12-16 09:59:16.162: I / dalvikvm-heap (1099): Grow heap (frag case) to 8.298MB for 5760016-byte allocation 12-16 09:59:16.202: D / dalvikvm (1099): GC_FOR_ALLOC freed <1K, 2% free 8433K/8540K, paused 38ms, total 38ms 12-16 09:59:16.942: D / gralloc_goldfish (1099):. Emulator without GPU emulation detected 12-16 09:59:19.142: D / dalvikvm (1099): GC_FOR_ALLOC freed 5K, 1% free 8457K/8540K, paused 111ms, total 145ms 12-16 09:59:19.322: I / dalvikvm-heap (1099): Grow heap (frag case) to 11.642MB for 3481616-byte allocation 12-16 09:59:19.442: D / dalvikvm (1099): GC_FOR_ALLOC freed <1K, 1% free 11857K/11944K, paused 116ms, total 116ms 12-16 09:59:22.122: I / Choreographer (1099):!. Skipped 32 frames The application may be doing too much work on its main thread 12-16 09:59:25.552: I / Choreographer (1099):!. Skipped 48 frames The application may be doing too much work on its main thread 12-16 09:59:27.712: D / AndroidRuntime (1099): Shutting down VM 12-16 09:59:27.712: W / dalvikvm (1099): threadid = 1: thread exiting with uncaught exception (group = 0xb3ac1b90) 12-16 09:59:27.752: E / AndroidRuntime (1099): FATAL EXCEPTION: main 12-16 09:59:27.752: E / AndroidRuntime (1099): Process: com.PicGenie, PID: 1099 12-16 09:59:27.752: E / AndroidRuntime (1099): java.lang.NumberFormatException: Invalid int: "" 12-16 09:59:27.752: E / AndroidRuntime (1099): at java.lang.Integer.invalidInt (Integer.java: 137) 12-16 09:59:27.752: E / AndroidRuntime (1099): at java.lang.Integer.parseInt (Integer.java: 358) 12-16 09:59:27.752: E / AndroidRuntime (1099): at java.lang.Integer.parseInt (Integer.java: 331) 12-16 09:59:27.752: E / AndroidRuntime (1099): at com.PicGenie.Activity_Login $ 2.onClick (Activity_Login.java: 72) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.view.View.performClick (View.java: 4424) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.view.View $ PerformClick.run (View.java: 18383) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.os.Handler.handleCallback (Handler.java: 733) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.os.Handler.dispatchMessage (Handler.java: 95) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.os.Looper.loop (Looper.java: 137) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.app.ActivityThread.main (ActivityThread.java: 4998) 12-16 09:59:27.752: E / AndroidRuntime (1099): at java.lang.reflect.Method.invokeNative (Native Method) 12-16 09:59:27.752: E / AndroidRuntime (1099): at java.lang.reflect.Method.invoke (Method.java: 515) 12-16 09:59:27.752: E / AndroidRuntime (1099): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 777) 12-16 09:59:27.752: E / AndroidRuntime (1099): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 593) 12-16 09:59:27.752: E / AndroidRuntime (1099): at dalvik.system.NativeStart.main (Native Method) 12-16 09:59:30.942: I / Process (1099): Sending signal PID:. 1099 SIG: 9
Reply:
Yes, yes, that is spending too much time login code above gave you written with multithreading.
There is: int account = Integer . ParseInt (userAccount.getText () toString ().); This place, userAccount first judgment under this control, you can not enter empty, otherwise it will be reported this error NumberFormatException Reply:
main thread properly properly networked database queries do not perform read and write large files
The main thread is a time limit (5S), if more than this time, there will be no response procedures. To avoid this situation, some of the time-consuming operation, and how the data exchange network, etc. In addition to open up a thread to handle. Downstairs is the code said. Reply:
The landlord did not print the error log posted ah? ? Click the login button guess it should be given, right? The login function into the thread execution.
/ / add event listeners login button btnLogining.setOnClickListener (new OnClickListener () { @ Override public void onClick (View v) { / / Get user input account final int account = Integer . ParseInt (userAccount.getText () toString ().); / / Get user input password final String password = userPwd.getText () toString ();. / / Call the login method new Thread () { public void run () { login (account, password); } .} Start ();
} });
12-16 09:59:16.092: D / dalvikvm (1099): GC_FOR_ALLOC freed 35K, 4% free 2808K/2912K, paused 40ms, total 41ms 12-16 09:59:16.162: I / dalvikvm-heap (1099): Grow heap (frag case) to 8.298MB for 5760016-byte allocation 12-16 09:59:16.202: D / dalvikvm (1099): GC_FOR_ALLOC freed <1K, 2% free 8433K/8540K, paused 38ms, total 38ms 12-16 09:59:16.942: D / gralloc_goldfish (1099):. Emulator without GPU emulation detected 12-16 09:59:19.142: D / dalvikvm (1099): GC_FOR_ALLOC freed 5K, 1% free 8457K/8540K, paused 111ms, total 145ms 12-16 09:59:19.322: I / dalvikvm-heap (1099): Grow heap (frag case) to 11.642MB for 3481616-byte allocation 12-16 09:59:19.442: D / dalvikvm (1099): GC_FOR_ALLOC freed <1K, 1% free 11857K/11944K, paused 116ms, total 116ms 12-16 09:59:22.122: I / Choreographer (1099):!. Skipped 32 frames The application may be doing too much work on its main thread 12-16 09:59:25.552: I / Choreographer (1099):!. Skipped 48 frames The application may be doing too much work on its main thread 12-16 09:59:27.712: D / AndroidRuntime (1099): Shutting down VM 12-16 09:59:27.712: W / dalvikvm (1099): threadid = 1: thread exiting with uncaught exception (group = 0xb3ac1b90) 12-16 09:59:27.752: E / AndroidRuntime (1099): FATAL EXCEPTION: main 12-16 09:59:27.752: E / AndroidRuntime (1099): Process: com.PicGenie, PID: 1099 12-16 09:59:27.752: E / AndroidRuntime (1099): java.lang.NumberFormatException: Invalid int: "" 12-16 09:59:27.752: E / AndroidRuntime (1099): at java.lang.Integer.invalidInt (Integer.java: 137) 12-16 09:59:27.752: E / AndroidRuntime (1099): at java.lang.Integer.parseInt (Integer.java: 358) 12-16 09:59:27.752: E / AndroidRuntime (1099): at java.lang.Integer.parseInt (Integer.java: 331) 12-16 09:59:27.752: E / AndroidRuntime (1099): at com.PicGenie.Activity_Login $ 2.onClick (Activity_Login.java: 72) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.view.View.performClick (View.java: 4424) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.view.View $ PerformClick.run (View.java: 18383) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.os.Handler.handleCallback (Handler.java: 733) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.os.Handler.dispatchMessage (Handler.java: 95) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.os.Looper.loop (Looper.java: 137) 12-16 09:59:27.752: E / AndroidRuntime (1099): at android.app.ActivityThread.main (ActivityThread.java: 4998) 12-16 09:59:27.752: E / AndroidRuntime (1099): at java.lang.reflect.Method.invokeNative (Native Method) 12-16 09:59:27.752: E / AndroidRuntime (1099): at java.lang.reflect.Method.invoke (Method.java: 515) 12-16 09:59:27.752: E / AndroidRuntime (1099): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 777) 12-16 09:59:27.752: E / AndroidRuntime (1099): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 593) 12-16 09:59:27.752: E / AndroidRuntime (1099): at dalvik.system.NativeStart.main (Native Method) 12-16 09:59:30.942: I / Process (1099): Sending signal PID:. 1099 SIG: 9
Yes, yes, that is spending too much time login code above gave you written with multithreading.
There is: int account = Integer . ParseInt (userAccount.getText () toString ().); This place, userAccount first judgment under this control, you can not enter empty, otherwise it will be reported NumberFormatException this wrong
12-16 22:21:54.405: D / dalvikvm (1708): GC_FOR_ALLOC freed 54K, 5% free 2808K/2940K, paused 187ms, total 190ms 12-16 22:21:54.475: I / dalvikvm-heap (1708): Grow heap (frag case) to 8.306MB for 5760016-byte allocation 12-16 22:21:54.555: D / dalvikvm (1708): GC_FOR_ALLOC freed <1K, 2% free 8433K/8568K, paused 73ms, total 73ms 12-16 22:21:55.265: D / gralloc_goldfish (1708):. Emulator without GPU emulation detected 12-16 22:21:57.225: D / dalvikvm (1708): GC_FOR_ALLOC freed 5K, 2% free 8458K/8568K, paused 55ms, total 57ms 12-16 22:21:57.345: I / dalvikvm-heap (1708): Grow heap (frag case) to 11.651MB for 3481616-byte allocation 12-16 22:21:57.505: D / dalvikvm (1708): GC_FOR_ALLOC freed <1K, 1% free 11857K/11972K, paused 152ms, total 152ms 12-16 22:22:00.625: I / Choreographer (1708):!. Skipped 185 frames The application may be doing too much work on its main thread 12-16 22:22:03.155: I / Choreographer (1708):!. Skipped 38 frames The application may be doing too much work on its main thread 12-16 22:22:28.185: I / Choreographer (1708): Skipped 35 frames The application may be doing too much work on its main thread !.12-16 22:22:28.975: I / Choreographer (1708):!. Skipped 44 frames The application may be doing too much work on its main thread 12-16 22:22:31.615: I / Choreographer (1708): Skipped 30 frames The application may be doing too much work on its main thread !.12-16 22:22:33.725: D / AndroidRuntime (1708): Shutting down VM 12-16 22:22:33.725: W / dalvikvm (1708): threadid = 1: thread exiting with uncaught exception (group = 0xb3a79b90) 12-16 22:22:33.745: E / AndroidRuntime (1708): FATAL EXCEPTION: main 12-16 22:22:33.745: E / AndroidRuntime (1708): Process: com.PicGenie, PID: 1708 12-16 22:22:33.745: E / AndroidRuntime (1708): java.lang.NumberFormatException: Invalid int: "tttuuyyyhg" 12-16 22:22:33.745: E / AndroidRuntime (1708): at java.lang.Integer.invalidInt (Integer.java: 137) 12-16 22:22:33.745: E / AndroidRuntime (1708): at java.lang.Integer.parse (Integer.java: 374) 12-16 22:22:33.745: E / AndroidRuntime (1708): at java.lang.Integer.parseInt (Integer.java: 365) 12-16 22:22:33.745: E / AndroidRuntime (1708): at java.lang.Integer.parseInt (Integer.java: 331) 12-16 22:22:33.745: E / AndroidRuntime (1708): at com.PicGenie.Activity_Login $ 2.onClick (Activity_Login.java: 75) 12-16 22:22:33.745: E / AndroidRuntime (1708): at android.view.View.performClick (View.java: 4424) 12-16 22:22:33.745: E / AndroidRuntime (1708): at android.view.View $ PerformClick.run (View.java: 18383) 12-16 22:22:33.745: E / AndroidRuntime (1708): at android.os.Handler.handleCallback (Handler.java: 733) 12-16 22:22:33.745: E / AndroidRuntime (1708): at android.os.Handler.dispatchMessage (Handler.java: 95) 12-16 22:22:33.745: E / AndroidRuntime (1708): at android.os.Looper.loop (Looper.java: 137) 12-16 22:22:33.745: E / AndroidRuntime (1708): at android.app.ActivityThread.main (ActivityThread.java: 4998) 12-16 22:22:33.745: E / AndroidRuntime (1708): at java.lang.reflect.Method.invokeNative (Native Method) 12-16 22:22:33.745: E / AndroidRuntime (1708): at java.lang.reflect.Method.invoke (Method.java: 515) 12-16 22:22:33.745: E / AndroidRuntime (1708): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 777) 12-16 22:22:33.745: E / AndroidRuntime (1708): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 593) 12-16 22:22:33.745: E / AndroidRuntime (1708): at dalvik.system.NativeStart.main (Native Method) 12-16 22:22:39.115: I / Process (1708): Sending signal PID:. 1708 SIG: 9
No comments:
Post a Comment