除了谷歌广告,我没有在我的活动中使用任何图片。但我得到 java.lang.outofmemoryerror 并且应用程序正在崩溃。
这是日志猫
03-25 18:24:22.125: E/AndroidRuntime(277): FATAL EXCEPTION: AsyncTask #2
03-25 18:24:22.125: E/AndroidRuntime(277): java.lang.RuntimeException: An error occured while executing doInBackground()
03-25 18:24:22.125: E/AndroidRuntime(277): at android.os.AsyncTask$3.done(AsyncTask.java:200)
03-25 18:24:22.125: E/AndroidRuntime(277): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
03-25 18:24:22.125: E/AndroidRuntime(277): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
03-25 18:24:22.125: E/AndroidRuntime(277): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
03-25 18:24:22.125: E/AndroidRuntime(277): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-25 18:24:22.125: E/AndroidRuntime(277): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
03-25 18:24:22.125: E/AndroidRuntime(277): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
03-25 18:24:22.125: E/AndroidRuntime(277): at java.lang.Thread.run(Thread.java:1096)
03-25 18:24:22.125: E/AndroidRuntime(277): Caused by: java.lang.OutOfMemoryError
03-25 18:24:22.125: E/AndroidRuntime(277): at org.kxml2.io.KXmlParser.push(KXmlParser.java:626)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.kxml2.io.KXmlParser.pushText(KXmlParser.java:865)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:354)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.kxml2.io.KXmlParser.next(KXmlParser.java:1385)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:210)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:366)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:233)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:366)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:121)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:137)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
03-25 18:24:22.125: E/AndroidRuntime(277): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
03-25 18:24:22.125: E/AndroidRuntime(277): at com.netserv.Pungry.RestaurantsList.SendRequesttoServer(RestaurantsList.java:207)
03-25 18:24:22.125: E/AndroidRuntime(277): at com.netserv.Pungry.RestaurantsList$ListData.doInBackground(RestaurantsList.java:148)
03-25 18:24:22.125: E/AndroidRuntime(277): at com.netserv.Pungry.RestaurantsList$ListData.doInBackground(RestaurantsList.java:1)
03-25 18:24:22.125: E/AndroidRuntime(277): at android.os.AsyncTask$2.call(AsyncTask.java:185)
03-25 18:24:22.125: E/AndroidRuntime(277): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-25 18:24:22.125: E/AndroidRuntime(277): ... 4 more
03-25 18:24:22.485: E/WindowManager(277): Activity com.netserv.Pungry.RestaurantsList has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43f0d2e8 that was originally added here
03-25 18:24:22.485: E/WindowManager(277): android.view.WindowLeaked: Activity com.netserv.Pungry.RestaurantsList has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43f0d2e8 that was originally added here
03-25 18:24:22.485: E/WindowManager(277): at android.view.ViewRoot.<init>(ViewRoot.java:247)
03-25 18:24:22.485: E/WindowManager(277): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
03-25 18:24:22.485: E/WindowManager(277): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
03-25 18:24:22.485: E/WindowManager(277): at android.view.Window$LocalWindowManager.addView(Window.java:424)
03-25 18:24:22.485: E/WindowManager(277): at android.app.Dialog.show(Dialog.java:241)
03-25 18:24:22.485: E/WindowManager(277): at com.netserv.Pungry.RestaurantsList$ListData.onPreExecute(RestaurantsList.java:159)
03-25 18:24:22.485: E/WindowManager(277): at android.os.AsyncTask.execute(AsyncTask.java:391)
03-25 18:24:22.485: E/WindowManager(277): at com.netserv.Pungry.RestaurantsList.onCreate(RestaurantsList.java:83)
03-25 18:24:22.485: E/WindowManager(277): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-25 18:24:22.485: E/WindowManager(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-25 18:24:22.485: E/WindowManager(277): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-25 18:24:22.485: E/WindowManager(277): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-25 18:24:22.485: E/WindowManager(277): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-25 18:24:22.485: E/WindowManager(277): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 18:24:22.485: E/WindowManager(277): at android.os.Looper.loop(Looper.java:123)
03-25 18:24:22.485: E/WindowManager(277): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-25 18:24:22.485: E/WindowManager(277): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 18:24:22.485: E/WindowManager(277): at java.lang.reflect.Method.invoke(Method.java:521)
03-25 18:24:22.485: E/WindowManager(277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-25 18:24:22.485: E/WindowManager(277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-25 18:24:22.485: E/WindowManager(277): at dalvik.system.NativeStart.main(Native Method)
这是我收到错误的 AsyncTask 类
public class ListData extends AsyncTask<String, Void, String> {
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
dialog.dismiss();
try {
if (!lstresponse.isEmpty()) {
lstresult.addAll(lstresponse);
GlobVariables.restaurant_response = lstresult;
lst_restaurant.setAdapter(CustAdapter);
} else
Toast.makeText(getApplicationContext(),
"No result found for" + " " + check,
Toast.LENGTH_LONG).show();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
SendRequesttoServer(params);
return "1";
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
dialog = new ProgressDialog(RestaurantsList.this);
dialog.setMessage("Please Wait...");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
}
}
public void SendRequesttoServer(String[] params) {
try {
if (GlobVariables.MenuSelectd.equals("Cuisine")
|| GlobVariables.Selecteditem.equals("Cuisines")) {
METHOD = "GetRestaurantsByCuisines";
request = new SoapObject(NAMESPACE, METHOD);
request.addProperty("cuisineName", params[0]);
request.addProperty("cityName", params[1]);
} else if (GlobVariables.MenuSelectd.equals("locations")
|| GlobVariables.Selecteditem.equals("Location")) {
METHOD = "GetRestaurantsByLocations";
request = new SoapObject(NAMESPACE, METHOD);
request.addProperty("location", params[0]);
request.addProperty("cityName", params[1]);
} else if (GlobVariables.Selecteditem.equals("ByName")) {
METHOD = "GetRestaurantsByName";
request = new SoapObject(NAMESPACE, METHOD);
request.addProperty("restaurantName", params[0]);
request.addProperty("cityName", params[1]);
} else {
METHOD = "SearchRestaurant";
request = new SoapObject(NAMESPACE, METHOD);
request.addProperty("searchParameter", params[0]);
request.addProperty("cityName", params[1]);
}
SOAP_ACTION = NAMESPACE + METHOD;
// SoapObject request = new SoapObject(NAMESPACE, METHOD);
// request.addProperty("location", params[0]);
// request.addProperty("cityName", params[1]);
check = params[0];
SoapSerializationEnvelope res = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
res.dotNet = true;
res.setOutputSoapObject(request);
HttpTransportSE call = new HttpTransportSE(url);
SoapPrimitive result;
call.call(SOAP_ACTION, res);
result = (SoapPrimitive) res.getResponse();
ParseDetails Objparsecities = new ParseDetails(
new ByteArrayInputStream(result.toString()
.getBytes("UTF-8")));
lstresponse = Objparsecities.parse();
System.out.println(lstresponse.size());
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我能知道为什么我收到 java.lang.outofmemoy 错误以及我在做什么错误吗?
谢谢:)