hunter123
Neues Mitglied
- 0
Hallo Leute,
ich erklär euch kurz wie meine App abläuft und dann das Problem:
1.Verbindung auf Mysql server - ListView wird befühlt(Funktioniert)
2.Ich klicke ein Item in der ListView und wechsle ins andere Layout
3.Bestehende Verbindung auf Mysql server -zweite ListView wird befühlt(Funktioniert)
4.Verbindung auf Mysql Server - holt sich alle Details(Funktioniert)
5.Befülle alle TextViews mit den geholten Items aus Mysql und BAMMM APP
stürzt ab ???
Ich mach alles über http also JSON
Hier der LogCat mit dem Fehler:
Java Code:
ich erklär euch kurz wie meine App abläuft und dann das Problem:
1.Verbindung auf Mysql server - ListView wird befühlt(Funktioniert)
2.Ich klicke ein Item in der ListView und wechsle ins andere Layout
3.Bestehende Verbindung auf Mysql server -zweite ListView wird befühlt(Funktioniert)
4.Verbindung auf Mysql Server - holt sich alle Details(Funktioniert)
5.Befülle alle TextViews mit den geholten Items aus Mysql und BAMMM APP
stürzt ab ???
Ich mach alles über http also JSON
Hier der LogCat mit dem Fehler:
Code:
08-19 16:07:00.728: D/dalvikvm(1552): GC_FOR_ALLOC freed 57K, 5% free 2900K/3024K, paused 35ms, total 37ms
08-19 16:07:00.798: D/dalvikvm(1552): GC_FOR_ALLOC freed 3K, 4% free 3315K/3440K, paused 24ms, total 24ms
08-19 16:07:00.948: D/dalvikvm(1552): GC_FOR_ALLOC freed 2K, 3% free 3646K/3756K, paused 23ms, total 23ms
08-19 16:07:00.958: I/dalvikvm-heap(1552): Grow heap (frag case) to 4.244MB for 651920-byte allocation
08-19 16:07:01.208: D/dalvikvm(1552): GC_FOR_ALLOC freed 1K, 3% free 4282K/4396K, paused 24ms, total 24ms
08-19 16:07:01.238: D/dalvikvm(1552): GC_FOR_ALLOC freed <1K, 3% free 4340K/4452K, paused 25ms, total 26ms
08-19 16:07:01.248: I/dalvikvm-heap(1552): Grow heap (frag case) to 4.906MB for 635812-byte allocation
08-19 16:07:01.338: D/dalvikvm(1552): GC_FOR_ALLOC freed <1K, 3% free 4961K/5076K, paused 24ms, total 25ms
08-19 16:07:01.968: I/Choreographer(1552): Skipped 100 frames! The application may be doing too much work on its main thread.
08-19 16:07:02.218: I/Choreographer(1552): Skipped 62 frames! The application may be doing too much work on its main thread.
08-19 16:07:02.318: D/gralloc_goldfish(1552): Emulator without GPU emulation detected.
08-19 16:07:02.538: I/Choreographer(1552): Skipped 53 frames! The application may be doing too much work on its main thread.
08-19 16:07:03.158: I/Choreographer(1552): Skipped 137 frames! The application may be doing too much work on its main thread.
08-19 16:07:04.688: D/All Category:(1552): {"success":1,"products":[{"id":"1","y":"15dp","x":"15dp","link":"http:\/\/5.175.164.200\/androidapps\/standalone\/category\/bilder\/b_backpack.png","name":"Backpacks"},{"id":"2","y":"15dp","x":"15dp","link":"http:\/\/5.175.164.200\/androidapps\/standalone\/category\/bilder\/b_weapons.png","name":"Waffen"},{"id":"3","y":"","x":"","link":"","name":"Essen & Trinken"},{"id":"4","y":"","x":"","link":"","name":"Kleidung"},{"id":"5","y":"","x":"","link":"","name":"Medizin "},{"id":"6","y":"","x":"","link":"","name":"Crafting"}]}
08-19 16:07:04.808: I/Choreographer(1552): Skipped 41 frames! The application may be doing too much work on its main thread.
08-19 16:07:05.528: W/IInputConnectionWrapper(1552): showStatusIcon on inactive InputConnection
08-19 16:07:24.398: D/dalvikvm(1552): GC_FOR_ALLOC freed 265K, 6% free 5431K/5760K, paused 90ms, total 102ms
08-19 16:07:24.688: I/Choreographer(1552): Skipped 243 frames! The application may be doing too much work on its main thread.
08-19 16:07:25.308: I/Choreographer(1552): Skipped 129 frames! The application may be doing too much work on its main thread.
08-19 16:07:25.488: D/All ItemsNames:(1552): {"success":1,"products":[{"bild3":"keine","id":"1","beschreib":null,"slots":"30 Slots","bild2":"keine","name":"Hunting Backpack","repair":"keine","bild":"keine","fundort":"Residential\/Civilian, Industrial, General Military"}]}
08-19 16:07:26.038: I/Choreographer(1552): Skipped 180 frames! The application may be doing too much work on its main thread.
08-19 16:07:26.858: I/Choreographer(1552): Skipped 178 frames! The application may be doing too much work on its main thread.
08-19 16:07:30.828: I/Choreographer(1552): Skipped 205 frames! The application may be doing too much work on its main thread.
08-19 16:07:31.568: D/AndroidRuntime(1552): Shutting down VM
08-19 16:07:31.568: W/dalvikvm(1552): threadid=1: thread exiting with uncaught exception (group=0xb1a24ba8)
08-19 16:07:31.628: E/AndroidRuntime(1552): FATAL EXCEPTION: main
08-19 16:07:31.628: E/AndroidRuntime(1552): Process: com.sdf.test, PID: 1552
08-19 16:07:31.628: E/AndroidRuntime(1552): android.os.NetworkOnMainThreadException
08-19 16:07:31.628: E/AndroidRuntime(1552): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
08-19 16:07:31.628: E/AndroidRuntime(1552): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
08-19 16:07:31.628: E/AndroidRuntime(1552): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
08-19 16:07:31.628: E/AndroidRuntime(1552): at libcore.io.IoBridge.connect(IoBridge.java:112)
08-19 16:07:31.628: E/AndroidRuntime(1552): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
08-19 16:07:31.628: E/AndroidRuntime(1552): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
08-19 16:07:31.628: E/AndroidRuntime(1552): at java.net.Socket.connect(Socket.java:843)
08-19 16:07:31.628: E/AndroidRuntime(1552): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
08-19 16:07:31.628: E/AndroidRuntime(1552): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
08-19 16:07:31.628: E/AndroidRuntime(1552): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-19 16:07:31.628: E/AndroidRuntime(1552): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-19 16:07:31.628: E/AndroidRuntime(1552): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
08-19 16:07:31.628: E/AndroidRuntime(1552): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-19 16:07:31.628: E/AndroidRuntime(1552): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-19 16:07:31.628: E/AndroidRuntime(1552): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-19 16:07:31.628: E/AndroidRuntime(1552): at com.sdf.test.JSONParser.makeHttpRequest(JSONParser.java:62)
08-19 16:07:31.628: E/AndroidRuntime(1552): at com.sdf.test.EditProductActivity$GetProductDetails$1.run(EditProductActivity.java:120)
08-19 16:07:31.628: E/AndroidRuntime(1552): at android.os.Handler.handleCallback(Handler.java:733)
08-19 16:07:31.628: E/AndroidRuntime(1552): at android.os.Handler.dispatchMessage(Handler.java:95)
08-19 16:07:31.628: E/AndroidRuntime(1552): at android.os.Looper.loop(Looper.java:136)
08-19 16:07:31.628: E/AndroidRuntime(1552): at android.app.ActivityThread.main(ActivityThread.java:5017)
08-19 16:07:31.628: E/AndroidRuntime(1552): at java.lang.reflect.Method.invokeNative(Native Method)
08-19 16:07:31.628: E/AndroidRuntime(1552): at java.lang.reflect.Method.invoke(Method.java:515)
08-19 16:07:31.628: E/AndroidRuntime(1552): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
08-19 16:07:31.628: E/AndroidRuntime(1552): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
08-19 16:07:31.628: E/AndroidRuntime(1552): at dalvik.system.NativeStart.main(Native Method)
Java Code:
Code:
package com.sdf.test;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class EditProductActivity extends Activity {
TextView linkBild;
TextView linkBild2;
TextView linkBild3;
TextView txtName;
TextView txtSlots;
TextView txtRepair;
TextView txtLocation;
TextView txtBeschreibung;
String pid;
// Progress Dialog
private ProgressDialog pDialog;
// JSON parser class
JSONParser jsonParser = new JSONParser();
// single product url
private static final String url_product_detials = "http://5.175.164.200/androidapps/standalone/access/get_backpack_details.php";
// JSON Node names
private static final String TAG_SUCCESS = "success";
private static final String TAG_PRODUCT = "product";
private static final String TAG_PID = "pid";
//private static final String TAG_BILD1 = "bild";
//private static final String TAG_BILD2 = "bild2";
//private static final String TAG_BILD3 = "bild3";
private static final String TAG_NAME = "name";
private static final String TAG_SLOTS = "slots";
private static final String TAG_REPAIR = "repair";
private static final String TAG_LOCATION = "location";
private static final String TAG_BESCHREIBUNG = "beschreibung";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ausgabedetails);
// getting product details from intent
Intent i = getIntent();
// getting product id (pid) from intent
pid = i.getStringExtra(TAG_PID);
// Getting complete product details in background thread
new GetProductDetails().execute();
}
/**
* Background Async Task to Get complete product details
* */
class GetProductDetails extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(EditProductActivity.this);
pDialog.setMessage("Loading. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Getting product details in background thread
* */
protected String doInBackground(String... params) {
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
// Check for success tag
int success;
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", pid));
// getting product details by making HTTP request
// Note that product details url will use GET request
JSONObject json = jsonParser.makeHttpRequest(
url_product_detials, "GET", params);
// check your log for json response
Log.d("Single Product Details", json.toString());
// json success tag
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully received product details
JSONArray productObj = json
.getJSONArray(TAG_PRODUCT); // JSON Array
// get first product object from JSON Array
JSONObject product = productObj.getJSONObject(0);
// product with this pid found
//linkBild = (TextView) findViewById(R.id.bild_backpack);
//linkBild2 = (TextView) findViewById(R.id.bild2_backpack);
//linkBild3 = (TextView) findViewById(R.id.bild3_backpack);
txtName = (TextView) findViewById(R.id.itemnametextview);
txtSlots = (TextView) findViewById(R.id.slotstextview);
txtRepair = (TextView) findViewById(R.id.fixtextview);
txtLocation = (TextView) findViewById(R.id.locationtextview);
txtBeschreibung = (TextView) findViewById(R.id.beschreibtextview);
// display product data in EditText
//linkBild.setText(product.getString(TAG_BILD1));
//linkBild2.setText(product.getString(TAG_BILD2));
//linkBild3.setText(product.getString(TAG_BILD3));
txtName.setText(product.getString(TAG_NAME));
txtSlots.setText(product.getString(TAG_SLOTS));
txtRepair.setText(product.getString(TAG_REPAIR));
txtLocation.setText(product.getString(TAG_LOCATION));
txtBeschreibung.setText(product.getString(TAG_BESCHREIBUNG));
}else{
// product with pid not found
}
} 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 got all details
pDialog.dismiss();
}
}
}