2013-01-07 4 views
0
package com.whatstherex.sam; 

import java.util.ArrayList; 

import org.apache.http.NameValuePair; 
import org.apache.http.message.BasicNameValuePair; 

import android.app.Activity; 
import android.app.AlertDialog; 
import android.app.ProgressDialog; 
import android.content.Context; 
import android.content.DialogInterface; 
import android.content.Intent; 
import android.graphics.Color; 
import android.os.AsyncTask; 
import android.os.Bundle; 
import android.os.StrictMode; 
import android.view.MotionEvent; 
import android.view.View; 
import android.view.inputmethod.InputMethodManager; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.LinearLayout; 
import android.widget.TabHost; 
import android.widget.TabHost.TabSpec; 
import android.widget.TextView; 

public class Login extends Activity { 
String emailAdd; 
EditText lEmail, lPassword, rUsername, rPassword, rRpassword, rEmail, 
     rPhoneNum, rBirthday, rGender; 
Button lLogin, rRegister; 
TextView lAuth, rAuth; 
AlertDialog loginDialog, registerDialog; 
LinearLayout Llayout, Rlayout; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); 
    StrictMode.setThreadPolicy(policy); 
    setContentView(R.layout.login); 

    initialize(); 
} 

@Override 
protected void onPause() { 
    // TODO Auto-generated method stub 
    super.onPause(); 
    finish(); 
} 

public void initialize() { 
    TabHost tabH = (TabHost) findViewById(R.id.tabhost); 
    tabH.setup(); 
    TabSpec specs = tabH.newTabSpec("tag1"); 
    specs.setContent(R.id.Login); 
    specs.setIndicator("Login"); 
    tabH.addTab(specs); 
    TabSpec specs1 = tabH.newTabSpec("tag2"); 
    specs1.setContent(R.id.Register); 
    specs1.setIndicator("Register"); 
    tabH.addTab(specs1); 

    lEmail = (EditText) findViewById(R.id.etlEmail); 
    lPassword = (EditText) findViewById(R.id.etlPassword); 
    lLogin = (Button) findViewById(R.id.blLogin); 
    lAuth = (TextView) findViewById(R.id.tvlAuth); 

    rUsername = (EditText) findViewById(R.id.etrUsername); 
    rPassword = (EditText) findViewById(R.id.etrpassword); 
    rRpassword = (EditText) findViewById(R.id.etrRpassword); 
    rEmail = (EditText) findViewById(R.id.etrEmail); 
    rPhoneNum = (EditText) findViewById(R.id.etrPnumber); 
    rBirthday = (EditText) findViewById(R.id.etrBirthday); 
    rGender = (EditText) findViewById(R.id.etrGender); 
    rRegister = (Button) findViewById(R.id.brRegister); 
    rAuth = (TextView) findViewById(R.id.tvrAuth); 

    hideKeyboardLayout(Llayout, R.id.Login); 
    hideKeyboardLayout(Rlayout, R.id.Register); 

    setLogin(lLogin); 
    setRegister(rRegister); 
} 

public void hideKeyboardLayout(LinearLayout layout, int name) { 
    layout = (LinearLayout) findViewById(name); 

    layout.setOnTouchListener(new View.OnTouchListener() { 

     protected void hideKeyboard(View v) { 
      InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
      in.hideSoftInputFromWindow(v.getWindowToken(), 
        InputMethodManager.HIDE_NOT_ALWAYS); 
     } 

     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      // TODO Auto-generated method stub 
      hideKeyboard(v); 
      return false; 
     } 
    }); 
} 

public void setLogin(Button b) { 
    b.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View v) { 
      // TODO Auto-generated method stub// TODO Auto-generated method stub 
      new loadLogin().execute(); 
     } 
    }); 
} 

private void setRegister(Button b) { 
    // TODO Auto-generated method stub 
    b.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      registerDialog = new AlertDialog.Builder(Login.this).create(); 
      registerDialog.setTitle("Register Alert!"); 
      registerDialog.setButton(DialogInterface.BUTTON_NEGATIVE, 
        "Back", new DialogInterface.OnClickListener() { 

         public void onClick(DialogInterface dialog, 
           int which) { 
          // TODO Auto-generated method stub 
          registerDialog.dismiss(); 
         } 
        }); 

      ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); 
      postParameters.add(new BasicNameValuePair("usernamelog", 
        rUsername.getText().toString())); 
      postParameters.add(new BasicNameValuePair("passwordlog", 
        rPassword.getText().toString())); 
      postParameters.add(new BasicNameValuePair("rpasswordlog", 
        rRpassword.getText().toString())); 
      postParameters.add(new BasicNameValuePair("emaillog", rEmail 
        .getText().toString())); 
      postParameters.add(new BasicNameValuePair("phonenumlog", 
        rPhoneNum.getText().toString())); 
      postParameters.add(new BasicNameValuePair("doblog", rBirthday 
        .getText().toString())); 
      postParameters.add(new BasicNameValuePair("genderlog", rGender 
        .getText().toString())); 

      String response = null; 

      try { 
       response = CustomHttpClient.executeHttpPost("http://whatstherex.info/CheckR.php", postParameters); 

       String res = response.toString(); 

       res = res.replaceAll("null", ""); 

       if (res.equals("1")) { 
        rAuth.setText("Successfully Register"); 
        rAuth.setTextColor(Color.GREEN); 
        registerDialog.setMessage("Successfully Register"); 
        registerDialog.show(); 
       } else { 
        rAuth.setText(res.toString()); 
        rAuth.setTextColor(Color.RED); 
        registerDialog.setMessage(res.toString()); 
        registerDialog.show(); 
       } 
      } catch (Exception e) { 
       rAuth.setText(e.toString()); 
       rAuth.setTextColor(Color.BLACK); 
      } 
     } 
    }); 
} 

public class loadLogin extends AsyncTask<String, Void, String> { 
    ProgressDialog dialog; 

    protected void onPreExecute(){ 
    dialog = new ProgressDialog(Login.this, ProgressDialog.STYLE_SPINNER); 
    dialog.setMessage("Loading Data..."); 
    dialog.show(); 
    } 

    @Override 
    protected String doInBackground(String... params) { 
     loginDialog = new AlertDialog.Builder(Login.this).create(); 
     loginDialog.setTitle("Login Alert!"); 
     loginDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Back", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int which) { 
       // TODO Auto-generated method stub 
       loginDialog.dismiss(); 
       } 
      }); 

     ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); 
     postParameters.add(new BasicNameValuePair("emaillog", lEmail.getText().toString())); 
     postParameters.add(new BasicNameValuePair("passwordlog", lPassword.getText().toString())); 

     String response = null; 

     String res = ""; 
     try { 
      response = CustomHttpClient.executeHttpPost("http://whatstherex.info/checkL.php", postParameters); 

      res = response.toString(); 

      res = res.replaceAll("null", ""); 

      if (res.equals("1")) { 
       res = "Login Successfully!"; 
       lAuth.setTextColor(Color.GREEN); 
       loginDialog.setMessage("Login Successfully!"); 
       loginDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Continue", new DialogInterface.OnClickListener() { 

        public void onClick(DialogInterface dialog, int which) { 
         // TODO Auto-generated method stub 
         new loadRedirect().execute(); 
         } 
        }); 
       loginDialog.show(); 
       dialog.dismiss(); 
       return res; 
      } else if (res.equals("0")) { 
       res = "Sorry!! Incorrect Username or Password!"; 
       lAuth.setTextColor(Color.RED); 
       loginDialog.setMessage("Sorry!! Incorrect Username or Password!"); 
       loginDialog.show(); 
       dialog.dismiss(); 
       return res; 
      } else { 
       res = res.toString(); 
       lAuth.setTextColor(Color.RED); 
       loginDialog.setMessage(res.toString()); 
       loginDialog.show(); 
       dialog.dismiss(); 
       return res; 
      } 

     } catch (Exception e) { 
      res = e.toString(); 
      lAuth.setTextColor(Color.BLACK); 
    } 
    return res; 
} 

protected void onProgressUpdate() { 

} 

protected void onPostExecute(String result){ 
    lAuth.setText(result); 
    dialog.dismiss(); 
} 

} 

public class loadRedirect extends AsyncTask<String, Void, String> { 
    ProgressDialog dialog; 

    protected void onPreExecute(){ 
    dialog = new ProgressDialog(Login.this, ProgressDialog.STYLE_SPINNER); 
    dialog.setMessage("Loading Data..."); 
    dialog.show(); 
    } 

    @Override 
    protected String doInBackground(String... params) { 
     ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); 
     postParameters.add(new BasicNameValuePair("emaillog", lEmail.getText().toString())); 
     postParameters.add(new BasicNameValuePair("passwordlog", lPassword.getText().toString())); 

     String response = null; 

     String res = ""; 
     try { 
      response = CustomHttpClient.executeHttpPost("http://whatstherex.info/checkP.php", postParameters); 

      res = response.toString(); 

      res = res.replaceAll("null", ""); 

      if (res.equals("1")) { 
       Intent mainIntent = new Intent("com.whatstherex.sam.Main"); 
       mainIntent.putExtra("Email", lEmail.getText().toString()); 
       startActivity(mainIntent); 
       dialog.dismiss(); 

      } else if (res.equals("0")) { 
       Intent profilePicIntent = new Intent("com.whatstherex.sam.Profilepic"); 
       profilePicIntent.putExtra("Email", lEmail.getText().toString()); 
       startActivity(profilePicIntent); 
       dialog.dismiss(); 
      } else { 
       res = res.toString(); 
       lAuth.setTextColor(Color.RED); 
       loginDialog.setMessage(res.toString()); 
       loginDialog.show(); 
       dialog.dismiss(); 
      } 

     } catch (Exception e) { 
      res = e.toString(); 
      lAuth.setTextColor(Color.BLACK); 
      } 
    return res; 
} 

protected void onProgressUpdate() { 

} 

protected void onPostExecute(String result){ 
    lAuth.setText(result); 
    dialog.dismiss(); 
} 

} 

} 

로딩 회전을 추가 할 필요가 있습니다. ui는 멈추고 충돌 할 수도 있습니다. 내가 2 개의 AsyncTask로 전체 덩어리를 정확하게 브레이크 아웃했는지 확실하지 않습니다. 또한 상쾌한 의도에 대한 다른 방법은 다른 감사합니다 finish(); 왜냐하면 그건 검은 화면을 줄 것이기 때문입니다. 어떤 도움이라도 대단히 감사하겠습니다. 안드로이드 개발 : AsyncTask의 progressdialog 여전히 여전히 응용 프로그램이 충돌합니다.

로그 파일입니다
01-07 08:58:44.984: D/dalvikvm(6078): Debugger has detached; object registry had 1 entries 
01-07 08:58:45.355: D/AndroidRuntime(6090): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
01-07 08:58:45.355: D/AndroidRuntime(6090): CheckJNI is OFF 
01-07 08:58:45.725: D/AndroidRuntime(6090): Calling main entry com.android.commands.am.Am 
01-07 08:58:45.735: I/ActivityManager(1679): Force stopping package com.whatstherex.sam uid=10111 
01-07 08:58:45.735: D/ViewRootImpl(1679): @@@- disable SystemServer HW acceleration 
01-07 08:58:45.735: I/ActivityManager(1679): START intent from pid 6090 
01-07 08:58:45.755: W/memalloc(1448): Falling back to ashmem 
01-07 08:58:45.775: D/memalloc(1448): ashmem: Allocated buffer base:0x42542000 size:1536000 fd:47 
01-07 08:58:45.775: D/memalloc(1679): ashmem: Mapped buffer base:0x55fb4000 size:1536000 fd:350 
01-07 08:58:45.785: I/Adreno200-EGLSUB(1448): <CreateImage:893>: Android Image 
01-07 08:58:45.785: I/Adreno200-EGLSUB(1448): <GetImageAttributes:1102>: RGBA_8888 
01-07 08:58:45.795: D/CAT(1878): CatService: Return current sInstance 
01-07 08:58:45.815: D/AndroidRuntime(6090): Shutting down VM 
01-07 08:58:45.825: D/dalvikvm(6100): Late-enabling CheckJNI 
01-07 08:58:45.825: I/AndroidRuntime(6090): NOTE: attach of thread 'Binder Thread #3' failed 
01-07 08:58:45.825: D/dalvikvm(6090): GC_CONCURRENT freed 106K, 70% free 615K/2048K, paused 0ms+2ms 
01-07 08:58:45.825: D/jdwp(6090): Got wake-up signal, bailing out of select 
01-07 08:58:45.825: D/dalvikvm(6090): Debugger has detached; object registry had 1 entries 
01-07 08:58:45.825: I/ActivityManager(1679): Start proc com.whatstherex.sam for activity com.whatstherex.sam/.Splash: pid=6100 uid=10111 gids={3003} 
01-07 08:58:45.855: D/SensorManager(1679): [SensorManager] registerListener: delay = 200000 
01-07 08:58:45.855: D/SensorService(1679): enable: get sensor name = BMA150 3-axis Accelerometer 
01-07 08:58:45.855: D/Sensors(1679): Enable akm: en = 1 
01-07 08:58:45.865: D/SensorService(1679): SensorDevice::activate--: handle = 0x0, enabled = 0x1 
01-07 08:58:45.865: D/SensorService(1679): pid=1679, uid=1000 
01-07 08:58:45.865: D/ConnectivityService(1679): onUidRulesChanged(uid=10111, uidRules=0) 
01-07 08:58:45.875: D/AK8975(1458): Compass Start 
01-07 08:58:45.875: V/WindowManager(1679): Starting animation in AppWindowToken{412e69f0 token=Token{412f5898 ActivityRecord{412f5648 com.htc.launcher/.Launcher}}} @ 160693935 
01-07 08:58:45.875: V/WindowManager(1679): Finished animation in AppWindowToken{412e69f0 token=Token{412f5898 ActivityRecord{412f5648 com.htc.launcher/.Launcher}}} @ 160693935 
01-07 08:58:45.885: V/WindowManager(1679): Starting animation in AppWindowToken{418942a0 token=Token{41836990 ActivityRecord{41836858 com.whatstherex.sam/.Splash}}} @ 160693935 
01-07 08:58:45.895: W/ActivityThread(6100): Application com.whatstherex.sam is waiting for the debugger on port 8100... 
01-07 08:58:45.905: I/System.out(6100): Sending WAIT chunk 
01-07 08:58:45.925: I/dalvikvm(6100): Debugger is active 
01-07 08:58:45.925: D/ViewRootImpl(1679): @@@- disable SystemServer HW acceleration 
01-07 08:58:45.945: D/OpenGLRenderer(1794): Flushing caches (mode 1) 
01-07 08:58:45.965: W/memalloc(1448): Falling back to ashmem 
01-07 08:58:45.975: D/AK8975(1458): Ignore M_Sensor: (y, p, r) = (269, 5, 2), Status = 2 
01-07 08:58:45.985: D/memalloc(1448): ashmem: Allocated buffer base:0x41c57000 size:737280 fd:48 
01-07 08:58:46.025: D/memalloc(1679): ashmem: Mapped buffer base:0x5612b000 size:737280 fd:363 
01-07 08:58:46.055: I/Adreno200-EGLSUB(1448): <CreateImage:893>: Android Image 
01-07 08:58:46.055: I/Adreno200-EGLSUB(1448): <GetImageAttributes:1102>: RGBA_8888 
01-07 08:58:46.095: W/dalvikvm(1794): disableGcForExternalAlloc: false 
01-07 08:58:46.105: I/System.out(6100): Debugger has connected 
01-07 08:58:46.105: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:46.306: V/WindowManager(1679): Finished animation in AppWindowToken{418942a0 token=Token{41836990 ActivityRecord{41836858 com.whatstherex.sam/.Splash}}} @ 160694367 
01-07 08:58:46.316: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:46.336: D/AndroidRuntime(6116): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
01-07 08:58:46.336: D/AndroidRuntime(6116): CheckJNI is OFF 
01-07 08:58:46.386: D/AndroidRuntime(6120): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
01-07 08:58:46.386: D/AndroidRuntime(6120): CheckJNI is OFF 
01-07 08:58:46.516: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:46.596: D/memalloc(1448): ashmem: Freeing buffer base:0x421f5000 size:1536000 fd:103 
01-07 08:58:46.596: D/memalloc(1448): ashmem: Freeing buffer base:0x42e1f000 size:1536000 fd:112 
01-07 08:58:46.696: E/SurfaceTexture(1448): [SurfaceView] abandon: SurfaceTexture(0x0x6239e8) has been abandoned! 
01-07 08:58:46.696: D/memalloc(1448): ashmem: Freeing buffer base:0x42042000 size:1536000 fd:37 
01-07 08:58:46.716: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:46.736: D/OpenGLRenderer(1794): Flushing caches (mode 0) 
01-07 08:58:46.916: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:46.936: D/memalloc(1448): ashmem: Freeing buffer base:0x42b6d000 size:1536000 fd:105 
01-07 08:58:46.936: W/memalloc(1448): Falling back to ashmem 
01-07 08:58:46.936: D/memalloc(1448): ashmem: Allocated buffer base:0x42042000 size:737280 fd:37 
01-07 08:58:46.936: D/memalloc(1448): ashmem: Freeing buffer base:0x42fa7000 size:1536000 fd:113 
01-07 08:58:46.946: D/memalloc(1679): ashmem: Mapped buffer base:0x561df000 size:737280 fd:366 
01-07 08:58:46.946: I/Adreno200-EGLSUB(1448): <CreateImage:893>: Android Image 
01-07 08:58:46.946: I/Adreno200-EGLSUB(1448): <GetImageAttributes:1102>: RGBA_8888 
01-07 08:58:46.966: E/SurfaceTexture(1448): [com.htc.launcher/com.htc.launcher.Launcher] abandon: SurfaceTexture(0x0x62a9e0) has been abandoned! 
01-07 08:58:46.996: D/memalloc(1448): ashmem: Freeing buffer base:0x41ecb000 size:1536000 fd:31 
01-07 08:58:47.116: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:47.306: D/AndroidRuntime(6116): Calling main entry com.android.commands.am.Am 
01-07 08:58:47.317: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:47.327: D/AndroidRuntime(6120): Calling main entry com.android.commands.am.Am 
01-07 08:58:47.327: D/AndroidRuntime(6116): Shutting down VM 
01-07 08:58:47.327: I/ActivityManager(1679): debugger status changed, pid: 6100, uid:10111, attach:true 
01-07 08:58:47.347: I/AndroidRuntime(6116): NOTE: attach of thread 'Binder Thread #3' failed 
01-07 08:58:47.347: D/dalvikvm(6116): GC_CONCURRENT freed 104K, 72% free 581K/2048K, paused 0ms+0ms 
01-07 08:58:47.347: D/jdwp(6116): Got wake-up signal, bailing out of select 
01-07 08:58:47.347: D/dalvikvm(6116): Debugger has detached; object registry had 1 entries 
01-07 08:58:47.357: I/com.fd.httpd(26432): onStart 
01-07 08:58:47.357: D/AndroidRuntime(6120): Shutting down VM 
01-07 08:58:47.367: I/AndroidRuntime(6120): NOTE: attach of thread 'Binder Thread #3' failed 
01-07 08:58:47.367: D/dalvikvm(6120): GC_CONCURRENT freed 106K, 71% free 613K/2048K, paused 1ms+1ms 
01-07 08:58:47.367: D/jdwp(6120): Got wake-up signal, bailing out of select 
01-07 08:58:47.367: D/dalvikvm(6120): Debugger has detached; object registry had 1 entries 
01-07 08:58:47.517: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:47.717: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:47.917: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:48.117: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:48.317: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:48.518: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:48.718: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:48.878: D/PhoneStatusBarPolicy(1760): ServiceState ss: 0 
01-07 08:58:48.888: D/PhoneStatusBarPolicy(1760): Network Type: 8 
01-07 08:58:48.918: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:49.128: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:49.328: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:49.529: I/System.out(6100): waiting for debugger to settle... 
01-07 08:58:49.729: I/System.out(6100): debugger has settled (1338) 
01-07 08:58:49.979: D/libEGL(6100): loaded /system/lib/egl/libGLES_android.so 
01-07 08:58:49.989: D/libEGL(6100): loaded /system/lib/egl/libEGL_adreno200.so 
01-07 08:58:49.989: E/SurfaceTexture(1448): [Waiting For Debugger] abandon: SurfaceTexture(0x0x622fc8) has been abandoned! 
01-07 08:58:49.989: D/memalloc(1448): ashmem: Freeing buffer base:0x41c57000 size:737280 fd:48 
01-07 08:58:49.989: D/memalloc(1448): ashmem: Freeing buffer base:0x42042000 size:737280 fd:37 
01-07 08:58:49.999: D/libEGL(6100): loaded /system/lib/egl/libGLESv1_CM_adreno200.so 
01-07 08:58:49.999: D/libEGL(6100): loaded /system/lib/egl/libGLESv2_adreno200.so 
01-07 08:58:50.019: I/Adreno200-EGLSUB(6100): <ConfigWindowMatch:2078>: Format RGBA_8888. 
01-07 08:58:50.019: W/memalloc(1448): Falling back to ashmem 
01-07 08:58:50.029: D/memalloc(1448): ashmem: Allocated buffer base:0x41ecb000 size:1536000 fd:31 
01-07 08:58:50.029: D/memalloc(6100): ashmem: Mapped buffer base:0x52287000 size:1536000 fd:62 
01-07 08:58:50.039: D/OpenGLRenderer(6100): Enabling debug mode 0 
01-07 08:58:50.049: W/InputManagerService(1679): Got RemoteException sending setActive(false) notification to pid 5529 uid 10111 
01-07 08:58:50.049: I/InputManagerService(1679): [startInputLocked] Enable input method client. 
01-07 08:58:50.099: W/memalloc(1448): Falling back to ashmem 
01-07 08:58:50.119: D/memalloc(1448): ashmem: Allocated buffer base:0x42104000 size:1536000 fd:37 
01-07 08:58:50.119: D/memalloc(6100): ashmem: Mapped buffer base:0x525b5000 size:1536000 fd:65 
01-07 08:58:50.119: I/Adreno200-EGLSUB(1448): <CreateImage:893>: Android Image 
01-07 08:58:50.119: I/Adreno200-EGLSUB(1448): <GetImageAttributes:1102>: RGBA_8888 
01-07 08:58:50.119: I/ActivityManager(1679): Displayed com.whatstherex.sam/.Splash: +4s309ms 
01-07 08:58:50.159: D/OpenGLRenderer(1794): Flushing caches (mode 2) 
01-07 08:58:50.159: D/ConnectivityService(1679): onUidRulesChanged(uid=9999, uidRules=0) 
01-07 08:58:50.319: E/SurfaceTexture(1448): [Starting com.whatstherex.sam] abandon: SurfaceTexture(0x0x626710) has been abandoned! 
01-07 08:58:50.319: D/memalloc(1448): ashmem: Freeing buffer base:0x42542000 size:1536000 fd:47 
01-07 08:58:50.620: V/WindowManager(1679): onProposedRotationChanged, rotation changed to 0 
01-07 08:58:50.790: D/skia(1794): AndroidImageRef[ 0x135d460 ] releasePixel fail as lockCount=1 
01-07 08:58:51.881: V/WindowManager(1679): onProposedRotationChanged, rotation changed to 0 
01-07 08:58:51.881: D/AndroidRuntime(6145): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
01-07 08:58:51.881: D/AndroidRuntime(6145): CheckJNI is OFF 
01-07 08:58:52.261: D/AndroidRuntime(6145): Calling main entry com.android.commands.am.Am 
01-07 08:58:52.271: I/com.fd.httpd(26432): onStart 
01-07 08:58:52.271: D/AndroidRuntime(6145): Shutting down VM 
01-07 08:58:52.281: I/AndroidRuntime(6145): NOTE: attach of thread 'Binder Thread #3' failed 
01-07 08:58:52.281: D/dalvikvm(6145): GC_CONCURRENT freed 106K, 71% free 613K/2048K, paused 0ms+0ms 
01-07 08:58:52.281: D/jdwp(6145): Got wake-up signal, bailing out of select 
01-07 08:58:52.281: D/dalvikvm(6145): Debugger has detached; object registry had 1 entries 
01-07 08:58:54.924: I/ActivityManager(1679): START intent from pid 6100 
01-07 08:58:55.444: I/Adreno200-EGLSUB(6100): <ConfigWindowMatch:2078>: Format RGBA_8888. 
01-07 08:58:55.444: W/memalloc(1448): Falling back to ashmem 
01-07 08:58:55.444: D/memalloc(1448): ashmem: Allocated buffer base:0x42542000 size:1536000 fd:47 
01-07 08:58:55.454: D/memalloc(6100): ashmem: Mapped buffer base:0x5282c000 size:1536000 fd:72 
01-07 08:58:55.545: W/SubtypeSwitcher(1863): Current subtype: en_US, keyboard 
01-07 08:58:55.545: W/SubtypeSwitcher(1863): Last subtype was disabled. Update to the current one. 
01-07 08:58:55.545: E/AbstractCompatWrapper(1863): Invalid input to AbstructCompatWrapper 
01-07 08:58:55.545: E/CompatUtils(1863): Exception in invoke: NullPointerException 
01-07 08:58:55.545: W/SubtypeSwitcher(1863): Update subtype to:en_US,keyboard, from: en_US, keyboard 
01-07 08:58:55.545: D/SubtypeSwitcher(1863): Update shortcut IME from : com.google.android.voicesearch/.ime.VoiceInputMethodService, , voice 
01-07 08:58:55.555: D/SubtypeSwitcher(1863): Update shortcut IME to : com.google.android.voicesearch/.ime.VoiceInputMethodService, , voice 
01-07 08:58:55.555: I/HTCIMEService(1863): fetch result: 8.5 
01-07 08:58:55.555: I/HTCIMEService(1863): fetch result: 8.5 
01-07 08:58:55.585: I/XT9_C(1863): [loadDefaultDB] xt9_raw/ldb_0409.ldb size=304198 (loaded) 
01-07 08:58:55.595: I/XT9_C(1863): [registerXT9LDB] ldb_0409.ldb loading [done] 
01-07 08:58:55.595: D/XT9_C(1863): [registerXT9LDB] current LdbNum=109, First LdbNum=109, Second LdbNum=0 
01-07 08:58:55.605: I/XT9_C(1863): [loadDefaultDB] xt9_raw/kbd_0d09.kbd size=20852 (loaded) 
01-07 08:58:55.605: I/XT9IMEAutoComplete(1863): [hanldeDBContentSensitive] set PDSwitch's OnDiagnoseListener for Email4PDSwitch 
01-07 08:58:55.605: I/HTCIMMView(1863): [FixedWCL] adjustWCLHeight height:65 
01-07 08:58:55.635: W/memalloc(1448): Falling back to ashmem 
01-07 08:58:55.635: D/memalloc(1448): ashmem: Allocated buffer base:0x41c57000 size:860160 fd:64 
01-07 08:58:55.635: D/memalloc(1863): ashmem: Mapped buffer base:0x527bb000 size:860160 fd:66 
01-07 08:58:55.695: D/dalvikvm(1863): GC_FOR_ALLOC freed 720K, 29% free 7708K/10787K, paused 55ms 
01-07 08:58:55.735: I/Adreno200-EGLSUB(1448): <CreateImage:893>: Android Image 
01-07 08:58:55.735: I/Adreno200-EGLSUB(1448): <GetImageAttributes:1102>: RGBA_8888 
01-07 08:58:55.755: D/OpenGLRenderer(6100): has fontRender patch 
01-07 08:58:55.775: D/OpenGLRenderer(6100): has fontRender patch 
01-07 08:58:55.825: D/OpenGLRenderer(6100): has fontRender patch 
01-07 08:58:55.825: W/memalloc(1448): Falling back to ashmem 
01-07 08:58:55.845: D/memalloc(1448): ashmem: Allocated buffer base:0x42b6d000 size:1536000 fd:67 
01-07 08:58:55.845: D/memalloc(6100): ashmem: Mapped buffer base:0x52b29000 size:1536000 fd:75 
01-07 08:58:55.845: I/Adreno200-EGLSUB(1448): <CreateImage:893>: Android Image 
01-07 08:58:55.845: I/Adreno200-EGLSUB(1448): <GetImageAttributes:1102>: RGBA_8888 
01-07 08:58:55.855: I/ActivityManager(1679): Displayed com.whatstherex.sam/.Login: +875ms 
01-07 08:58:55.855: V/WindowManager(1679): Starting animation in AppWindowToken{418942a0 token=Token{41836990 ActivityRecord{41836858 com.whatstherex.sam/.Splash}}} @ 160703906 
01-07 08:58:55.855: V/WindowManager(1679): Finished animation in AppWindowToken{418942a0 token=Token{41836990 ActivityRecord{41836858 com.whatstherex.sam/.Splash}}} @ 160703906 
01-07 08:58:55.855: V/WindowManager(1679): Starting animation in AppWindowToken{41814af8 token=Token{417bfa58 ActivityRecord{417bf920 com.whatstherex.sam/.Login}}} @ 160703906 
01-07 08:58:55.875: D/OpenGLRenderer(6100): Flushing caches (mode 0) 
01-07 08:58:55.875: D/memalloc(1448): ashmem: Freeing buffer base:0x42104000 size:1536000 fd:37 
01-07 08:58:55.885: E/SurfaceTexture(1448): [com.whatstherex.sam/com.whatstherex.sam.Splash] abandon: SurfaceTexture(0x0x6239e8) has been abandoned! 
01-07 08:58:55.895: D/memalloc(1448): ashmem: Freeing buffer base:0x41ecb000 size:1536000 fd:31 
01-07 08:58:56.065: W/memalloc(1448): Falling back to ashmem 
01-07 08:58:56.075: V/WindowManager(1679): Finished animation in AppWindowToken{41814af8 token=Token{417bfa58 ActivityRecord{417bf920 com.whatstherex.sam/.Login}}} @ 160704136 
01-07 08:58:56.085: D/memalloc(1448): ashmem: Allocated buffer base:0x41ecb000 size:1536000 fd:31 
01-07 08:58:56.095: D/memalloc(6100): ashmem: Mapped buffer base:0x52287000 size:1536000 fd:63 
01-07 08:58:56.095: I/Adreno200-EGLSUB(1448): <CreateImage:893>: Android Image 
01-07 08:58:56.095: I/Adreno200-EGLSUB(1448): <GetImageAttributes:1102>: RGBA_8888 
01-07 08:58:56.115: D/dalvikvm(1794): GC_BEFORE_OOM freed 150K, 51% free 7261K/14563K, paused 247ms 
01-07 08:58:56.556: I/Adreno200-EGLSUB(1448): <CreateImage:893>: Android Image 
01-07 08:58:56.556: I/Adreno200-EGLSUB(1448): <GetImageAttributes:1102>: RGBA_8888 
01-07 08:58:56.876: D/AndroidRuntime(6159): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
01-07 08:58:56.876: D/AndroidRuntime(6159): CheckJNI is OFF 
01-07 08:58:57.286: D/AndroidRuntime(6159): Calling main entry com.android.commands.am.Am 
01-07 08:58:57.296: I/com.fd.httpd(26432): onStart 
01-07 08:58:57.296: D/AndroidRuntime(6159): Shutting down VM 
01-07 08:58:57.306: I/AndroidRuntime(6159): NOTE: attach of thread 'Binder Thread #3' failed 
01-07 08:58:57.306: D/dalvikvm(6159): GC_CONCURRENT freed 106K, 71% free 613K/2048K, paused 0ms+0ms 
01-07 08:58:57.306: D/jdwp(6159): Got wake-up signal, bailing out of select 
01-07 08:58:57.306: D/dalvikvm(6159): Debugger has detached; object registry had 1 entries 
01-07 08:58:57.877: D/PhoneStatusBarPolicy(1760): ServiceState ss: 0 
01-07 08:58:57.877: D/PhoneStatusBarPolicy(1760): Network Type: 8 
01-07 08:58:59.138: I/Adreno200-EGLSUB(6100): <ConfigWindowMatch:2078>: Format RGBA_8888. 
01-07 08:58:59.148: W/memalloc(1448): Falling back to ashmem 
01-07 08:58:59.148: D/memalloc(1448): ashmem: Allocated buffer base:0x419a8000 size:245760 fd:37 
01-07 08:58:59.148: D/memalloc(6100): ashmem: Mapped buffer base:0x521a8000 size:245760 fd:61 

이 또한 내가 디버그에서 가져온 오류가

Thread [<11> AsyncTask #1] (Suspended (exception RuntimeException)) 
    <VM does not provide monitor information> 
    ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1094 
    ThreadPoolExecutor$Worker.run() line: 569 
    Thread.run() line: 864 
+2

이 충돌하는 경우, 예외가 무엇입니까? – Ameen

+0

귀하의 logcat을 게시하십시오. 또한, 왜 당신은'onPause()'에서'finish()'를 부를까요? ?? – 323go

+0

로그를 업로드하고 예외 이름을 – Sam

답변

0

당신은 UI를 다른 스레드 (하지 UI 스레드)에서 어떤 방법을 수정할 수 없습니다 . 따라서 AsyncTask.doInBackground 메소드에서 대화 상자를 생성/표시/해제하는 것은 비합법적이며 충돌이 발생합니다.

+0

으로 지정했습니다. 그러면 다른 alertDialog를 열고 다른 인 텐트로 이동하기 위해 다른 방법으로 대화 상자를 닫을 수 있습니다. – Sam

+0

다양한 방법이 있습니다. 예를 들어, 다음과 같이 loadLogin을 수정할 수 있습니다. - doInBackground 메소드에서 모든 대화 로직을 제거합니다. doInBackground에서 게시 요청을 실행하고 결과를 반환합니다. - onPostExecute에서 진행률 대화 상자를 닫고 결과를 분석하고 적절한 로그인 대화 상자를 만들거나 표시합니다. – Leonidos

+0

@ user1953739 onPostExecute에서 다른 alertDialog를 여는 함수를 호출해야합니다. 즉, asynctask 작업이 완료되고 다른 인 텐트로 갈 수 있음을 의미합니다 – Zyoo

0

doInBackground에서 이렇게하지 마십시오. UI 스레드가 아닙니다.

protected String doInBackground(String... params) 

통과하고 대화 상자를 닫하려는 경우 이후에 아무것도를 평가하지 않는 경우 (onPostExcecute()에 평가 :

loginDialog = new AlertDialog.Builder(Login.this).create(); 
loginDialog.setTitle("Login Alert!"); 
loginDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Back", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int which) { 
     // TODO Auto-generated method stub 
     loginDialog.dismiss(); 
    } 
}); 

당신은 당신이 이유 인 문자열로 작업을 반환 할 수 있습니다 작업이 완료되면 String 대신 Void을 입력하십시오. 대화 상자를 만들려면 onPreExecute()에서 수행하십시오. 둘 다 UI 스레드에서 실행됩니다. 예를 들어

:

@Override 
protected void onPreExecute() { 
super.onPreExecute(); 
    progressDialog = new ProgressDialog(context); 
    progressDialog.setCancelable(false); 
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
    progressDialog.setMessage("Sending message...."); 
    progressDialog.show(); 
} 

http://developer.android.com/reference/android/os/AsyncTask.html#onPostExecute(Result)

관련 문제