Jump to content

Android com MySQL


Acejakk
 Share

Go to solution Solved by KTachyon,

Recommended Posts

Boas!

Queria começar um projecto que involve a app que estou a criar ligar-se a uma base de dados MySql.

encontrei um tutorial em Androidhive.com e já tenho a aplicação a correr mas dá-me alguns erros quando tento ligar à base de dados. Alguém consegue ajudar?

Agradecido desde já,

Guilherme Correia

http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/

JSON Parser Class:

package com.example.androidhive;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class JSONParser {

static InputStream is = null;
static JSONObject jObj = null;
static String json = "";

// constructor
public JSONParser() {

}

// function get json from url
// by making HTTP POST or GET mehtod
public JSONObject makeHttpRequest(String url, String method,
								 List<NameValuePair> params) {

	// Making HTTP request
	try {

		// check for request method
		if(method == "POST"){
			// request method is POST
			// defaultHttpClient
			DefaultHttpClient httpClient = new DefaultHttpClient();
			HttpPost httpPost = new HttpPost(url);
			httpPost.setEntity(new UrlEncodedFormEntity(params));

			HttpResponse httpResponse = httpClient.execute(httpPost);
			HttpEntity httpEntity = httpResponse.getEntity();
			is = httpEntity.getContent();

		}else if(method == "GET"){
			// request method is GET
			DefaultHttpClient httpClient = new DefaultHttpClient();
			String paramString = URLEncodedUtils.format(params, "utf-8");
			url += "?" + paramString;
			HttpGet httpGet = new HttpGet(url);

			HttpResponse httpResponse = httpClient.execute(httpGet);
			HttpEntity httpEntity = httpResponse.getEntity();
			is = httpEntity.getContent();
		}

	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	} catch (ClientProtocolException e) {
		e.printStackTrace();
	} catch (IOException e) {
		e.printStackTrace();
	}

	try {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				is, "iso-8859-1"), 8);
		StringBuilder sb = new StringBuilder();
		String line = null;
		while ((line = reader.readLine()) != null) {
			sb.append(line + "\n");
		}
		is.close();
		json = sb.toString();
	} catch (Exception e) {
		Log.e("Buffer Error", "Error converting result " + e.toString());
	}

	// try parse the string to a JSON object
	try {
		jObj = new JSONObject(json);
	} catch (JSONException e) {
		Log.e("JSON Parser", "Error parsing data " + e.toString());
	}

	// return JSON String
	return jObj;

}
}

AllProductsActivity Class:

package com.example.androidhive;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class AllProductsActivity extends ListActivity {

// Progress Dialog
private ProgressDialog pDialog;

// Creating JSON Parser object
JSONParser jParser = new JSONParser();

ArrayList<HashMap<String, String>> productsList;

// url to get all products list
private static String url_all_products = "http://192.168.1.68/android_connect/get_all_products.php";

// JSON Node names
private static final String TAG_SUCCESS = "success";
private static final String TAG_PRODUCTS = "products";
private static final String TAG_PID = "pid";
private static final String TAG_NAME = "name";

// products JSONArray
JSONArray products = null;

@Override
public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.all_products);

 // Hashmap for ListView
 productsList = new ArrayList<HashMap<String, String>>();

 // Loading products in Background Thread
 new LoadAllProducts().execute();

 // Get listview
 ListView lv = getListView();

 // on seleting single product
 // launching Edit Product Screen
 lv.setOnItemClickListener(new OnItemClickListener() {

	 @Override
	 public void onItemClick(AdapterView<?> parent, View view,
							 int position, long id) {
		 // getting values from selected ListItem
		 String pid = ((TextView) view.findViewById(R.id.pid)).getText()
				 .toString();

		 // Starting new intent
		 Intent in = new Intent(getApplicationContext(),
				 EditProductActivity.class);
		 // sending pid to next activity
		 in.putExtra(TAG_PID, pid);

		 // starting new activity and expecting some response back
		 startActivityForResult(in, 100);
	 }
 });

}

// Response from Edit Product Activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 super.onActivityResult(requestCode, resultCode, data);
 // if result code 100
 if (resultCode == 100) {
	 // if result code 100 is received
	 // means user edited/deleted product
	 // reload this screen again
	 Intent intent = getIntent();
	 finish();
	 startActivity(intent);
 }

}

/**
 * Background Async Task to Load all product by making HTTP Request
 * */
class LoadAllProducts extends AsyncTask<String, String, String> {

 /**
	 * Before starting background thread Show Progress Dialog
	 * */
 @Override
 protected void onPreExecute() {
	 super.onPreExecute();
	 pDialog = new ProgressDialog(AllProductsActivity.this);
	 pDialog.setMessage("Loading products. Please wait...");
	 pDialog.setIndeterminate(false);
	 pDialog.setCancelable(false);
	 pDialog.show();
 }

 /**
	 * getting All products from url
	 * */
 protected String doInBackground(String... args) {
	 // Building Parameters
	 List<NameValuePair> params = new ArrayList<NameValuePair>();

	 // getting JSON string from URL
	 JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);

	 // Check your log cat for JSON reponse
	 Log.d("All Products: ", json.toString());

	 try {
		 // Checking for SUCCESS TAG
		 int success = json.getInt(TAG_SUCCESS);

		 if (success == 1) {
			 // products found
			 // Getting Array of Products
			 products = json.getJSONArray(TAG_PRODUCTS);

			 // looping through All Products
			 for (int i = 0; i < products.length(); i++) {
				 JSONObject c = products.getJSONObject(i);

				 // Storing each json item in variable
				 String id = c.getString(TAG_PID);
				 String name = c.getString(TAG_NAME);

				 // creating new HashMap
				 HashMap<String, String> map = new HashMap<String, String>();

				 // adding each child node to HashMap key => value
				 map.put(TAG_PID, id);
				 map.put(TAG_NAME, name);

				 // adding HashList to ArrayList
				 productsList.add(map);
			 }
		 } else {
			 // no products found
			 // Launch Add New product Activity
			 Intent i = new Intent(getApplicationContext(),
					 NewProductActivity.class);
			 // Closing all previous activities
			 i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			 startActivity(i);
		 }
	 } catch (JSONException e) {
		 e.printStackTrace();
	 }

	 return null;
 }

 /**
	 * After completing background task Dismiss the progress dialog
	 * **/
 protected void onPostExecute(String file_url) {
	 // dismiss the dialog after getting all products
	 pDialog.dismiss();
	 // updating UI from Background Thread
	 runOnUiThread(new Runnable() {
		 public void run() {
			 /**
				 * Updating parsed JSON data into ListView
				 * */
			 ListAdapter adapter = new SimpleAdapter(
					 AllProductsActivity.this, productsList,
					 R.layout.list_item, new String[] { TAG_PID,
					 TAG_NAME},
					 new int[] { R.id.pid, R.id.name });
			 // updating listview
			 setListAdapter(adapter);
		 }
	 });

 }

}
}

LogCat error:

09-22 14:46:10.282	3782-3822/com.example.androidhive E/JSON Parser﹕ Error parsing data org.json.JSONException: Value Unknown of type java.lang.String cannot be converted to JSONObject
09-22 14:46:10.282	3782-3822/com.example.androidhive W/dalvikvm﹕ threadid=12: thread exiting with uncaught exception (group=0x41619ba8)
09-22 14:46:10.282	3782-3822/com.example.androidhive E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.example.androidhive, PID: 3782
java.lang.RuntimeException: An error occured while executing doInBackground()
		at android.os.AsyncTask$3.done(AsyncTask.java:300)
		at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
		at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
		at java.util.concurrent.FutureTask.run(FutureTask.java:242)
		at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
		at java.lang.Thread.run(Thread.java:841)
 Caused by: java.lang.NullPointerException
		at com.example.androidhive.AllProductsActivity$LoadAllProducts.doInBackground(AllProductsActivity.java:130)
		at com.example.androidhive.AllProductsActivity$LoadAllProducts.doInBackground(AllProductsActivity.java:105)
		at android.os.AsyncTask$2.call(AsyncTask.java:288)
		at java.util.concurrent.FutureTask.run(FutureTask.java:237)
		at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
		at java.lang.Thread.run(Thread.java:841)
09-22 14:46:10.723	3782-3782/com.example.androidhive E/WindowManager﹕ android.view.WindowLeaked: Activity com.example.androidhive.AllProductsActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41f33d98 V.E..... R......D 0,0-959,192} that was originally added here
		at android.view.ViewRootImpl.<init>(ViewRootImpl.java:346)
		at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
		at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
		at android.app.Dialog.show(Dialog.java:286)
		at com.example.androidhive.AllProductsActivity$LoadAllProducts.onPreExecute(AllProductsActivity.java:117)
		at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
		at android.os.AsyncTask.execute(AsyncTask.java:535)
		at com.example.androidhive.AllProductsActivity.onCreate(AllProductsActivity.java:57)
		at android.app.Activity.performCreate(Activity.java:5231)
		at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
		at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
		at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
		at android.app.ActivityThread.access$800(ActivityThread.java:135)
		at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
		at android.os.Handler.dispatchMessage(Handler.java:102)
		at android.os.Looper.loop(Looper.java:136)
		at android.app.ActivityThread.main(ActivityThread.java:5001)
		at java.lang.reflect.Method.invokeNative(Native Method)
		at java.lang.reflect.Method.invoke(Method.java:515)
		at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
		at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
		at dalvik.system.NativeStart.main(Native Method)
09-22 14:46:59.230	4413-4413/com.example.androidhive I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13
09-22 14:46:59.260	4413-4413/com.example.androidhive D/OpenGLRenderer﹕ Enabling debug mode 0
09-22 14:47:00.611	4413-4440/com.example.androidhive D/dalvikvm﹕ GC_FOR_ALLOC freed 216K, 3% free 9348K/9596K, paused 15ms, total 15ms
09-22 14:47:01.072	4413-4440/com.example.androidhive E/JSON Parser﹕ Error parsing data org.json.JSONException: Value Unknown of type java.lang.String cannot be converted to JSONObject
09-22 14:47:01.082	4413-4440/com.example.androidhive W/dalvikvm﹕ threadid=12: thread exiting with uncaught exception (group=0x41619ba8)
09-22 14:47:01.082	4413-4440/com.example.androidhive E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.example.androidhive, PID: 4413
java.lang.RuntimeException: An error occured while executing doInBackground()
		at android.os.AsyncTask$3.done(AsyncTask.java:300)
		at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
		at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
		at java.util.concurrent.FutureTask.run(FutureTask.java:242)
		at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
		at java.lang.Thread.run(Thread.java:841)
 Caused by: java.lang.NullPointerException
		at com.example.androidhive.AllProductsActivity$LoadAllProducts.doInBackground(AllProductsActivity.java:130)
		at com.example.androidhive.AllProductsActivity$LoadAllProducts.doInBackground(AllProductsActivity.java:105)
		at android.os.AsyncTask$2.call(AsyncTask.java:288)
		at java.util.concurrent.FutureTask.run(FutureTask.java:237)
		at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
		at java.lang.Thread.run(Thread.java:841)
09-22 14:47:01.512	4413-4413/com.example.androidhive E/WindowManager﹕ android.view.WindowLeaked: Activity com.example.androidhive.AllProductsActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41f31658 V.E..... R......D 0,0-959,192} that was originally added here
		at android.view.ViewRootImpl.<init>(ViewRootImpl.java:346)
		at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
		at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
		at android.app.Dialog.show(Dialog.java:286)
		at com.example.androidhive.AllProductsActivity$LoadAllProducts.onPreExecute(AllProductsActivity.java:117)
		at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
		at android.os.AsyncTask.execute(AsyncTask.java:535)
		at com.example.androidhive.AllProductsActivity.onCreate(AllProductsActivity.java:57)
		at android.app.Activity.performCreate(Activity.java:5231)
		at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
		at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
		at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
		at android.app.ActivityThread.access$800(ActivityThread.java:135)
		at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
		at android.os.Handler.dispatchMessage(Handler.java:102)
		at android.os.Looper.loop(Looper.java:136)
		at android.app.ActivityThread.main(ActivityThread.java:5001)
		at java.lang.reflect.Method.invokeNative(Native Method)
		at java.lang.reflect.Method.invoke(Method.java:515)
		at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
		at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
		at dalvik.system.NativeStart.main(Native Method)
Link to comment
Share on other sites

  • Solution

Não sei onde é que está a tua linha 130, mas se for a linha:

// Check your log cat for JSON reponse
Log.d("All Products: ", json.toString());

É possível que o teu objecto json seja null e, portanto, não podes chamar o método toString(). Confirma se o objecto é null.

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Link to comment
Share on other sites

correcto KTachyon. o defeito estava nos ficheiros php. quando retornava a query JSON vinha com os erros todos e portanto retornava primeiro os erros php e depois a query. dentro da app, a query JSON lia primeiro os erros portanto não mostrava nada. tão simples como esconder os erros no início do ficheiro php!

Link to comment
Share on other sites

Boas,

Eu aproveitei esse JSON Parser Class para criar uma aplicação que conseguisse conectar a uma base de dados.

Quando o user clica no botao chama a funcao (new CreateNewUser().execute() 😉

class CreateNewUser extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(SignIn.this);
pDialog.setMessage("Creating User..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}

/**
* Creating
* */
protected String doInBackground(String... args) {
String mail = EditText_mail.getText().toString();
String pwd = EditText_pass.getText().toString();
String pwd2 = EditText_verfPass.getText().toString();

// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("mail", mail));
params.add(new BasicNameValuePair("pass", pwd));

// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(url_create_product,
"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

Toast.makeText(SignIn.this, "JA ESTÁ ", Toast.LENGTH_SHORT).show();
// closing this screen

} else {
// failed to create product
Toast.makeText(SignIn.this, "ERRO ", Toast.LENGTH_SHORT).show();
}
} 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();
}

}

A aplicação nao tem erros, mas quando se clica no botao a aplicaçao termina e aprarece os seguntes erros:

02-19 23:28:26.379 5328-5389/com.comic.protect.mocoto.comic W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0x4183cce0)
02-19 23:28:26.477 5328-5389/com.comic.protect.mocoto.comic E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.comic.protect.mocoto.comic, PID: 5328
java.lang.RuntimeException: An error occured while executing doInBackground()
	 at android.os.AsyncTask$3.done(AsyncTask.java:300)
	 at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
	 at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
	 at java.util.concurrent.FutureTask.run(FutureTask.java:242)
	 at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
	 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
	 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
	 at java.lang.Thread.run(Thread.java:841)
 Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
	 at android.os.Handler.<init>(Handler.java:200)
	 at android.os.Handler.<init>(Handler.java:114)
	 at android.widget.Toast$TN.<init>(Toast.java:327)
	 at android.widget.Toast.<init>(Toast.java:92)
	 at android.widget.Toast.makeText(Toast.java:241)
	 at com.comic.protect.mocoto.comic.SignIn$CreateNewProduct.doInBackground(SignIn.java:141)
	 at com.comic.protect.mocoto.comic.SignIn$CreateNewProduct.doInBackground(SignIn.java:123)
	 at android.os.AsyncTask$2.call(AsyncTask.java:288)
	 at java.util.concurrent.FutureTask.run(FutureTask.java:237)
		at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
		at java.lang.Thread.run(Thread.java:841)

Pessoal conseguem-me ajudar? É que eu não consigo perceber isto!

Cumps

Link to comment
Share on other sites

O problema está na mensagem que estás a tentar mostrar via toast. Não está a correr na mesma thread.

Se procurasses o erro no google é o primeiro link..

http://stackoverflow.com/questions/3875184/cant-create-handler-inside-thread-that-has-not-called-looper-prepare

Apaguei essas mensagens via toast, mas mesmo assim o erro continua!

02-20 10:42:34.575  13952-14106/com.comic.protect.mocoto.comic W/dalvikvm﹕ threadid=12: thread exiting with uncaught exception (group=0x4183cce0)
02-20 10:42:34.645  13952-14106/com.comic.protect.mocoto.comic E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
   Process: com.comic.protect.mocoto.comic, PID: 13952

Que poderá ser mais?

Edited by Mocoto
Link to comment
Share on other sites

Está aqui o novo erro!

02-21 02:19:42.617 6579-6850/com.comic.protect.mocoto.comic W/dalvikvm﹕ threadid=12: thread exiting with uncaught exception (group=0x417b6ce0)
02-21 02:19:42.902 6579-6850/com.comic.protect.mocoto.comic E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.comic.protect.mocoto.comic, PID: 6579
java.lang.RuntimeException: An error occured while executing doInBackground()
	 at android.os.AsyncTask$3.done(AsyncTask.java:300)
	 at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
	 at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
	 at java.util.concurrent.FutureTask.run(FutureTask.java:242)
	 at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
	 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
	 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
	 at java.lang.Thread.run(Thread.java:841)
 Caused by: java.lang.NullPointerException
	 at com.comic.protect.mocoto.comic.SignIn$CreateNewUser.doInBackground(SignIn.java:141)
	 at com.comic.protect.mocoto.comic.SignIn$CreateNewUser.doInBackground(SignIn.java:123)
	 at android.os.AsyncTask$2.call(AsyncTask.java:288)
	 at java.util.concurrent.FutureTask.run(FutureTask.java:237)
		at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
		at java.lang.Thread.run(Thread.java:841)
02-21 02:19:43.441 6579-6579/com.comic.protect.mocoto.comic I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@41c1f818 time:6097292
02-21 02:19:43.761 6579-6579/com.comic.protect.mocoto.comic E/WindowManager﹕ android.view.WindowLeaked: Activity com.comic.protect.mocoto.comic.SignIn has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41cd4ed0 V.E..... R......D 0,0-456,144} that was originally added here
	 at android.view.ViewRootImpl.<init>(ViewRootImpl.java:346)
	 at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
	 at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
	 at android.app.Dialog.show(Dialog.java:286)
	 at com.comic.protect.mocoto.comic.SignIn$CreateNewUser.onPreExecute(SignIn.java:134)
	 at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
	 at android.os.AsyncTask.execute(AsyncTask.java:535)
	 at com.comic.protect.mocoto.comic.SignIn$1.onclick(SignIn.java:65)
	 at android.view.View.performClick(View.java:4445)
	 at android.view.View$PerformClick.run(View.java:18446)
	 at android.os.Handler.handleCallback(Handler.java:733)
	 at android.os.Handler.dispatchMessage(Handler.java:95)
	 at android.os.Looper.loop(Looper.java:136)
	 at android.app.ActivityThread.main(ActivityThread.java:5146)
	 at java.lang.reflect.Method.invokeNative(Native Method)
	 at java.lang.reflect.Method.invoke(Method.java:515)
	 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
	 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
	 at dalvik.system.NativeStart.main(Native Method)
02-21 02:19:50.992 6579-6850/com.comic.protect.mocoto.comic I/Process﹕ Sending signal. PID: 6579 SIG: 9
02-21 02:19:51.320 6924-6924/com.comic.protect.mocoto.comic D/ActivityThread﹕ handleBindApplication:com.comic.protect.mocoto.comic

I need help! 😉

Link to comment
Share on other sites

O erro está nestas linhas:

Caused by: java.lang.NullPointerException
at com.comic.protect.mocoto.comic.SignIn$CreateNewUser.doInBackground(SignIn.java:141)
at com.comic.protect.mocoto.comic.SignIn$CreateNewUser.doInBackground(SignIn.java:123)

Significa que há um valor que não foi inicializado ou que está nulo e te está a causar dissabores.

  • Vote 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.