我正在尝试在服务器上发布数据库不知道错误到底在哪里,但它似乎在 Asynctask 中检查 logcat
所以我真的不确定错误是来自 PHP 文件还是 Java 代码
07-07 20:07:30.533: E/WindowManager(1688): Activity com.example.ahliaevents.AddCard has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@421da710 that was originally added here
07-07 20:07:30.533: E/WindowManager(1688): android.view.WindowLeaked: Activity com.example.ahliaevents.AddCard has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@421da710 that was originally added here
07-07 20:07:30.533: E/WindowManager(1688): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:374)
07-07 20:07:30.533: E/WindowManager(1688): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:292)
07-07 20:07:30.533: E/WindowManager(1688): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
07-07 20:07:30.533: E/WindowManager(1688): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
07-07 20:07:30.533: E/WindowManager(1688): at android.view.Window$LocalWindowManager.addView(Window.java:547)
07-07 20:07:30.533: E/WindowManager(1688): at android.app.Dialog.show(Dialog.java:277)
07-07 20:07:30.533: E/WindowManager(1688): at com.example.ahliaevents.AddCard$CreateNewCard.onPreExecute(AddCard.java:75)
07-07 20:07:30.533: E/WindowManager(1688): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
07-07 20:07:30.533: E/WindowManager(1688): at android.os.AsyncTask.execute(AsyncTask.java:534)
07-07 20:07:30.533: E/WindowManager(1688): at com.example.ahliaevents.AddCard$1.onClick(AddCard.java:55)
07-07 20:07:30.533: E/WindowManager(1688): at android.view.View.performClick(View.java:4084)
07-07 20:07:30.533: E/WindowManager(1688): at android.view.View$PerformClick.run(View.java:16966)
07-07 20:07:30.533: E/WindowManager(1688): at android.os.Handler.handleCallback(Handler.java:615)
07-07 20:07:30.533: E/WindowManager(1688): at android.os.Handler.dispatchMessage(Handler.java:92)
07-07 20:07:30.533: E/WindowManager(1688): at android.os.Looper.loop(Looper.java:137)
07-07 20:07:30.533: E/WindowManager(1688): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-07 20:07:30.533: E/WindowManager(1688): at java.lang.reflect.Method.invokeNative(Native Method)
07-07 20:07:30.533: E/WindowManager(1688): at java.lang.reflect.Method.invoke(Method.java:511)
07-07 20:07:30.533: E/WindowManager(1688): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-07 20:07:30.533: E/WindowManager(1688): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-07 20:07:30.533: E/WindowManager(1688): at dalvik.system.NativeStart.main(Native Method)
这是我的课
public class AddCard extends Activity {
// Progress Dialog
private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();
EditText inputName,inputPhone,inputPosition,inputCollege;
// url to create new product
private static String url_create_card = "#####://####/####/#####.php";
// JSON Node names
private static final String TAG_SUCCESS = "success";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.addcard);
// Edit Text
inputName = (EditText) findViewById(R.id.addstudentname);
inputCollege = (EditText) findViewById(R.id.addstudentcollege);
inputPosition = (EditText) findViewById(R.id.addstudentposition);
inputPhone = (EditText) findViewById(R.id.addstudentphone);
// Create button
Button btnCreateProduct = (Button) findViewById(R.id.addcardsave);
// button click event
btnCreateProduct.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// creating new product in background thread
new CreateNewCard().execute();
}
});
}
/**
* Background Async Task to Create new product
* */
class CreateNewCard extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialo
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(AddCard.this);
pDialog.setMessage("Creating Student Card..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Creating product
* */
protected String doInBackground(String... args) {
String name = inputName.getText().toString();
String position = inputPosition.getText().toString();
String college = inputCollege.getText().toString();
String phone = inputPhone.getText().toString();
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("name", name));
params.add(new BasicNameValuePair("position", position));
params.add(new BasicNameValuePair("college", college));
params.add(new BasicNameValuePair("phone", phone));
// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(url_create_card,
"POST", params);
// check log cat fro response
Log.d("Create Response", json.toString());
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully created product
Intent i = new Intent(getApplicationContext(), MainActivity.class);
startActivity(i);
// closing this screen
finish();
} else {
// failed to create product
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once done
pDialog.dismiss();
}
}
}