I am currently working on a android app that needs to download everything from an online mySQL database, all of which will then be stored locally using the SQLite built into android.
The problem I am facing at the moment is making the connection from the android device to the server. I have not figured out how to pull information down yet.
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static android.content.ContentValues.TAG;
public class LoginWorker {
JSONParser jParser = new JSONParser();
ArrayList<HashMap<String, String>> usersList;
private static String url_all_users = "http://localhost/get_user_login.php";
private static String TAG_SUCCESS = "success";
private static String TAG_USERS = "users";
private static String TAG_EMAIL = "email";
private static String TAG_PASSWORD = "password";
JSONArray users = null;
public void onCreate(){
System.out.print("Login worker onCreate started");
usersList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<>();
map.put("test","test");
usersList.add(map);
Log.d(TAG, "onCreate: LoadAllUsers Running now");
new LoadAllUsers().execute();
}
class LoadAllUsers extends AsyncTask<String, String, String>{
protected void onPreExecute(){
super.onPreExecute();
}
protected String doInBackground(String... args){
Log.d(TAG, "doInBackground: Start of method");
List<NameValuePair> params = new ArrayList<NameValuePair>();
JSONObject json = jParser.makeHttpRequest(url_all_users, "GET", params);
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
users = json.getJSONArray(TAG_USERS);
for (int i = 0; i < users.length(); i++) {
JSONObject c = users.getJSONObject(i);
String password = c.getString(TAG_PASSWORD);
String email = c.getString(TAG_EMAIL);
HashMap<String, String> map = new HashMap<String, String>();
map.put(TAG_EMAIL, email);
map.put(TAG_PASSWORD, password);
usersList.add(map);
}
} else {
Log.d("doInBackground : ", "No user found");
}
}catch(JSONException e){
e.printStackTrace();
}
return null;
}
protected void onPostExecution(){}
}
This is an example of some of the code I have been working on (For the user login). Is there a simpler way to make this connection without having to use JSON and PHP? Any help will be greatly appreciated, even if it's just links to useful blogs or tutorials!
Follow these tutorials for connecting to mysql db and creating api which u can be used to retrieve data.
To Connect to db and create api:
https://www.simplifiedcoding.net/php-restful-api-framework-slim-tutorial-1/
https://www.simplifiedcoding.net/create-chat-app-for-android-using-gcm-1/
after creating api you can use retrofit to get data from api.
http://www.androidhive.info/2016/05/android-working-with-retrofit-http-library/
Related
I have an android studio project connected to a mysql online database, using php files.
The problem is I don't receive the parameters(idquestion, question, id) from the php file with a given idquestion and a category.
The class and the php file are a similar replica to ohers that works and yet is not working.
I tried the debugger and i find out that i pass the correct information (idquestion 1 and category "computers").
Also, i tried another php file with a different syntax just to print data and it worked, but that php file wasn't helpful in my class.
This is my php file
<?php
$con = mysqli_connect("localhost", "id8963226_user", "parola123", "id8963226_user");
$idquestion = #($_POST['idquestion']);
$category = #($_POST['category']);
$statement = mysqli_prepare($con, "select * from question where idquestion=? and category=?;");
mysqli_stmt_bind_param($statement, "is", $idquestion, $question);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $success, $idquestion, $question, $id);
$response = array();
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["idquestion"] = $idquestion;
$response["question"] = $question;
$response["id"] = $id;
}
echo json_encode($response);
?>
These are my java classes
package com.example.allrateform;
import android.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
public class Question extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_question);
//CREATING ALL INSTANCES FROM TEXTS
final TextView CategoryTextView = findViewById(R.id.CategoryTextView);
final TextView QuestionTextView = findViewById(R.id.QuestionTextView);
final TextView IdTextView = findViewById(R.id.IdTextView);
CategoryTextView.setText(Categories.Category);
final String category = CategoryTextView.getText().toString();
final int idquestion = 1;
Response.Listener<String> responseListener = new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if (success) {
String question = jsonResponse.getString("question");
int id = jsonResponse.getInt("id");
QuestionTextView.setText(question);
IdTextView.setText(id);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(Question.this);
builder.setMessage("Failed")
.setNegativeButton("Ok", null)
.create()
.show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
//CREATING RESPONSE
ListRequest listRequest = new ListRequest(idquestion, category, responseListener);
RequestQueue queue = Volley.newRequestQueue(Question.this);
queue.add(listRequest);
}
}
package com.example.allrateform;
import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;
import java.util.HashMap;
import java.util.Map;
public class ListRequest extends StringRequest {
private static final String LIST_REQUEST_URL = "myUrl.com/myPhp.php";
private Map<String, String> params;
//METHOD TO PASS THE INFORMATION
public ListRequest(int idquestion, String category, Response.Listener<String> listener) {
super(Method.POST, LIST_REQUEST_URL, listener, null);
params = new HashMap<>();
params.put("idquestion", idquestion + "");
params.put("category", category);
}
#Override
public Map<String, String> getParams() {
return params;
}
}
So again the project result is "Failed", meaning the php returns false.
If you have other ways to approach this it's ok as long as I'm able to store all the question from the "computer" categories in a java string array.
Feel free to ask any other questions about my database or other classes or anything.
Thank you in advance!
I got the problem.. it was a logic error in my php, binding ($statement, "is", $idquestion, $question) instead of ($statement, "is", $idquestion, $category) .. the given variables. Still, I don't how but i have another error now.
Look at the output
{"success":true,"idquestion":"Top programming languages?","question":"computers","id":1}
it was suppose to be
{"success":true,"idquestion":1,"question":"Top programming languages?","id":1}
I am doing in this code: message receiving,filtering and getting then sending data to a sql server. I need the category_id from mysql database. Then i will use it in CallAPI as ide . I took the data from my mysql database but i couldn't transfer the data one class to another. So how can i transfer the data from one class to another?
I solved my problem and updated it i hope it can help to another peoples.
my smsCame codes:
package com.pvalid.api;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import okhttp3.FormBody;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.Request;
import okhttp3.Response;
public class smsCame extends BroadcastReceiver {
private static final String TAG = "MyBroadcastReceiver";
#Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG , "SMS RECEIVEDD");
Bundle bundle = intent.getExtras();
Object[] pdus = (Object[]) bundle.get("pdus");
String format = intent.getExtras().getString("format");
SmsMessage message = SmsMessage.createFromPdu((byte[]) pdus[0], format);
String messagea = message.getOriginatingAddress();
String messagesb = message.getMessageBody();
Boolean messagee= messagesb.substring(0, 8).matches("(G-)\\d\\d\\d\\d\\d\\d");
String Code = messagesb.substring(2, 8);
String ide;
String usercode = "Admin";
//i need to POST this lmessage to my php server when sms received
//property is has to be Code:lmessage
// i have a receiver in my url when isset($_POST['Code'])
if (messagee){
try{
ide = new heyAPI(usercode).execute().get();
new CallAPI(usercode, Code, ide).execute();}
catch(Exception e){
ide="11";
new CallAPI(usercode, Code, ide).execute();
}
}
else{
Log.i(TAG,"Didnt match");}
}
private static class heyAPI extends AsyncTask<String, String, String> {
private final OkHttpClient client = new OkHttpClient();
String usercodes;
private heyAPI(String usercode){
usercodes= usercode;
}
#Override
protected void onPreExecute() {
super.onPreExecute();
}
#Override
protected String doInBackground(String... params) {
RequestBody formBody = new FormBody.Builder()
.add("usercode", usercodes) // A sample POST field
.build();
Request request = new Request.Builder()
.url("url-here")
.post(formBody)
.build();
try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
Headers responseHeaders = response.headers();
String elem_id= response.body().string();
return elem_id;
}
catch (Exception e){
Log.i(TAG,"Error:"+e);
return null;
}
}
#Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
}
}
private static class CallAPI extends AsyncTask<String, String, String> {
String emailString;
String commentString;
String id;
private CallAPI(String usercode, String Code,String ide){
emailString = usercode;
commentString = Code;
id=ide;
}
#Override
protected void onPreExecute() {
super.onPreExecute();
}
#Override
protected String doInBackground(String... params) {
OkHttpClient client = new OkHttpClient();
RequestBody formBody = new FormBody.Builder()
.add("usercode", emailString) // A sample POST field
.add("Code", commentString) // Another sample POST field
.add("category_id", id) // Another sample POST field
.build();
Request request = new Request.Builder()
.url("url here") // The URL to send the data to
.post(formBody)
.build();
try {
Response response = client.newCall(request).execute();
return response.body().string();
}catch(IOException e){
Log.i(TAG,"IO exception");
return "";
}
}
#Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
}
}
}
You can use transfer your data in different class by using database , shared preference and intents.
If You want to transfer data from class A to B by intent then
In class A
Intent intent = new Intent(getApplicationContext(), SecondActivity.class);
intent.putExtra("key_name", value);
startActivity(intent);
and In class B for getting the transferred data
Intent intent=new getIntent();
String s=intent.getExtras().getString("key_name");
hi you can send parameters class A to class B is so way...
you can use constructor like this
public class test {
public test(String p){...}
}
and you can use intent
you can use shared preference in
learn with this site Shared preference
save data from class A and read class B
and you must be careful because when you give data from server thread is different Ui thread !
private SharedPreferences mPreference;
mPreference = getSharedPreferences("Share", Context.MODE_PRIVATE);
// save data
mPreference.edit()
.putBoolean("test", category_id)
.apply();
// read data
mPreference.getString("test", defaultSTR);
Does anyone have any examples on how to create a page/wiki entry in Confluence using Confluence's RESTful API? I'm trying to write something in Java that can do this.
Thank you in advance...
Thank you, I already checked the documentation online but I couldn't find any examples THAT USE JAVA in the Confluence REST API. That's why I posted on here.
Regardless, I think I figured it out:
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/**
* Creates a Confluence wiki page via the RESTul API
* using an HTTP Post command.
*/
public class ConfluenceRestApi2CreateEntry {
//private static final String BASE_URL = "http://localhost:1990/confluence";
private static final String BASE_URL = "https://<context>.atlassian.net/wiki";
private static final String USERNAME = "username";
private static final String PASSWORD = "password";
private static final String ENCODING = "utf-8";
public static String createContentRestUrl()throws UnsupportedEncodingException
{
return String.format("%s/rest/api/content/?&os_authType=basic&os_username=%s&os_password=%s", BASE_URL, URLEncoder.encode(USERNAME, ENCODING), URLEncoder.encode(PASSWORD, ENCODING));
}
public static void main(final String[] args) throws Exception
{
String wikiPageTitle = "My Awesome Page";
String wikiPage = "<h1>Things That Are Awesome</h1><ul><li>Birds</li><li>Mammals</li><li>Decapods</li></ul>";
String wikiSpace = "JOUR";
String labelToAdd = "awesome_stuff";
int parentPageId = 9994250;
JSONObject newPage = defineConfluencePage(wikiPageTitle,
wikiPage,
wikiSpace,
labelToAdd,
parentPageId);
createConfluencePageViaPost(newPage);
}
public static void createConfluencePageViaPost(JSONObject newPage) throws Exception
{
HttpClient client = new DefaultHttpClient();
// Send update request
HttpEntity pageEntity = null;
try
{
//2016-12-18 - StirlingCrow: Left off here. Was finally able to get the post command to work
//I can begin testing adding more data to the value stuff (see above)
HttpPost postPageRequest = new HttpPost(createContentRestUrl());
StringEntity entity = new StringEntity(newPage.toString(), ContentType.APPLICATION_JSON);
postPageRequest.setEntity(entity);
HttpResponse postPageResponse = client.execute(postPageRequest);
pageEntity = postPageResponse.getEntity();
System.out.println("Push Page Request returned " + postPageResponse.getStatusLine().toString());
System.out.println("");
System.out.println(IOUtils.toString(pageEntity.getContent()));
}
finally
{
EntityUtils.consume(pageEntity);
}
}
public static JSONObject defineConfluencePage(String pageTitle,
String wikiEntryText,
String pageSpace,
String label,
int parentPageId) throws JSONException
{
//This would be the command in Python (similar to the example
//in the Confluence example:
//
//curl -u <username>:<password> -X POST -H 'Content-Type: application/json' -d'{
// "type":"page",
// "title":"My Awesome Page",
// "ancestors":[{"id":9994246}],
// "space":{"key":"JOUR"},
// "body":
// {"storage":
// {"value":"<h1>Things That Are Awesome</h1><ul><li>Birds</li><li>Mammals</li><li>Decapods</li></ul>",
// "representation":"storage"}
// },
// "metadata":
// {"labels":[
// {"prefix":"global",
// "name":"journal"},
// {"prefix":"global",
// "name":"awesome_stuff"}
// ]
// }
// }'
// http://localhost:8080/confluence/rest/api/content/ | python -mjson.tool
JSONObject newPage = new JSONObject();
// "type":"page",
// "title":"My Awesome Page"
newPage.put("type","page");
newPage.put("title", pageTitle);
// "ancestors":[{"id":9994246}],
JSONObject parentPage = new JSONObject();
parentPage.put("id",parentPageId);
JSONArray parentPageArray = new JSONArray();
parentPageArray.put(parentPage);
newPage.put("ancestors", parentPageArray);
// "space":{"key":"JOUR"},
JSONObject spaceOb = new JSONObject();
spaceOb.put("key",pageSpace);
newPage.put("space", spaceOb);
// "body":
// {"storage":
// {"value":"<p><h1>Things That Are Awesome</h1><ul><li>Birds</li><li>Mammals</li><li>Decapods</li></ul></p>",
// "representation":"storage"}
// },
JSONObject jsonObjects = new JSONObject();
jsonObjects.put("value", wikiEntryText);
jsonObjects.put("representation","storage");
JSONObject storageObject = new JSONObject();
storageObject.put("storage", jsonObjects);
newPage.put("body", storageObject);
//LABELS
// "metadata":
// {"labels":[
// {"prefix":"global",
// "name":"journal"},
// {"prefix":"global",
// "name":"awesome_stuff"}
// ]
// }
JSONObject prefixJsonObject1 = new JSONObject();
prefixJsonObject1.put("prefix","global");
prefixJsonObject1.put("name","journal");
JSONObject prefixJsonObject2 = new JSONObject();
prefixJsonObject2.put("prefix","global");
prefixJsonObject2.put("name",label);
JSONArray prefixArray = new JSONArray();
prefixArray.put(prefixJsonObject1);
prefixArray.put(prefixJsonObject2);
JSONObject labelsObject = new JSONObject();
labelsObject.put("labels", prefixArray);
newPage.put("metadata",labelsObject);
return newPage;
}
}
Here's a project in GitHub that I created that also has an example of simply pulling wiki page entry using Java:
https://github.com/stirlingcrow/Confluence-AccessRestApiWithJava
What about using the official REST client?
https://mvnrepository.com/artifact/com.atlassian.confluence/confluence-rest-client
I'm not able to find any documentation on how to use it, tho.
I have two similar program. the First: Java for PC, the Second: Android. I have a MacOS Pro Server with ip 192.168.0.103 in my local network. MacOS Server has got MySQL-Server 5.0.1, with
CREATE DATABASE db_demo01;
CREATE USER 'user01'#'%' IDENTIFIED BY '1234567';
GRANT ALL ON db_demo01.* TO 'user01'#'%';
My PC App has following code:
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://192.168.0.103:3306/";
String dbName = "db_demo01";
String userName = "user01";
String userPass = "1234567";
try
{
Class.forName(driver);
Connection conn = DriverManager.getConnection(url+dbName,userName,userPass);
System.out.println("Connected!");
conn.close();
}
catch(Exception ex)
{
System.out.println("Error:" + ex.getMessage());
}
It's work!But when I try to do this with my android app, I'v got connection fail. I don't know why... I posted the full code of my app below:
package com.navi.newser;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity {
/// VARIABLES
private TextView textWidget;
private TableLayout tableWidget;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CreateOnClickConnect();
}
private void CreateOnClickConnect()
{
textWidget = (TextView)findViewById(R.id.textView1);
tableWidget = (TableLayout)findViewById(R.id.table1);
Button cmd = (Button)this.findViewById(R.id.button3);
cmd.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
ConnectToMySQL();
}
});
}
private class Connect extends AsyncTask<String, String, String> {
#Override
protected String doInBackground(String... urls)
{
String response = "";
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://192.168.0.103:3306/";
String dbName = "db_demo01";
String userName = "user01";
String userPass = "1234567";
Connection conn = null;
try
{
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,userPass);
response += "Connected!";
Log.e("MySQL", response);
conn.close();
}
catch(Exception ex)
{
ex.printStackTrace();
response += "Error:" + ex.getMessage();
Log.e("MySQL", response);
}
publishProgress("Almost...");
return response;
}
#Override
protected void onPostExecute(String result) {
textWidget.setText(result);
}
#Override
protected void onProgressUpdate(String... text) {
textWidget.setText(text[0]);
}
}
public void ConnectToMySQL()
{
new Connect().execute();
}
I use Eclipse Luna.
01-20 19:09:07.777: E/dalvikvm(1069): Could not find class 'javax.naming.StringRefAddr', referenced from method com.mysql.jdbc.ConnectionPropertiesImpl$ConnectionProperty.storeTo
I don't have other errors.
The emulator is always isolated from your machine's network, take a look at this Network Address Space
Start your emulator with this
emulator -avd avdname -http-proxy http://192.168.0.1:8080
Here replace avdname to name of avd you want to run your program, and http:192.168.1.1 to your proxy server.
original answer
Well you have to make some settings; first of all with emulator isn't always a good idea to use it, while there is internet connection in the middle. Also the library (jar) for the connector should be in a folder called lib in Android project. For MySQL interaction, I use JSON with PHP. I hope this help you !
This question already has answers here:
How can I fix 'android.os.NetworkOnMainThreadException'?
(66 answers)
Closed 9 years ago.
I have a aspx page that I am calling from my android app that is returning JSON text but the java code below breaks here BufferedReader reader = new BufferedReader(new InputStreamReader(jc.getInputStream()));
with this error.
error android.os.NetworkOnMainThreadException
ARe you able to help plesae? Thanks
default.aspx return json
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "text/plain";
//Write the message
Response.Write("{'testvar':'testtext'}");
//End the response causing it to be sent
Response.End();
}
}
android java
public void connectWCF() {
try {
URL json = new URL("http://localhost:50851/Default.aspx");
URLConnection jc = json.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(jc.getInputStream()));
String line = reader.readLine();
reader.close();
} catch(Exception e){
}
links where I got the code ideas from
http://wyousuf.wordpress.com/2012/03/01/android-with-wcf-services/
http://matijabozicevic.com/blog/android-development/android-with-wcf-service
You are placing network communication on the main thread. You should use AsyncTask
http://developer.android.com/reference/android/os/AsyncTask.html
here's a nice video that explains JSON Parsing using AsyncTask.
http://www.youtube.com/watch?v=qcotbMLjlA4
For testing ONLY you can add the following in your Main Activity but it is consider bad practice.
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Since android 3.0, you can't put any calls to webpages or similar external resources in the main thread (in other words, any part of the activity) unless you do it with an AsyncTask, in order to avoid apps to look "locked" and unresponsive when waiting for a response from an external datasource. Therefore, you'll need to implement the webservice call with and AsyncTask.
Example class for AsyncTask:
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
public class cargaDatosRest extends AsyncTask<Context, Void, Void> {
private Context c;
private boolean resul = false;
private String control = "";
private String respStrS = "";
public cargaDatosRest(Context C)
{
c = C;
}
public String getStr()
{
return respStrS;
}
public String getControl()
{
return control;
}
#Override
protected void onPreExecute() {
super.onPreExecute();
//mProgressDialog.show();
}
#Override
protected Void doInBackground(Context... params) {
HttpClient httpClient = new DefaultHttpClient();
HttpGet get = new HttpGet("url");
HttpResponse resp;
get.setHeader("content-type", "application/json");
try
{
/*resp contains the response from the webService. respStr and respJSON allows to read that resp in JSON format. Just delete them if you don't need them. You can asign the values returned by the webservice to local variables in the AsyncTask class and then read them with public methods, like the resul variable.*/
resp = httpClient.execute(getUsuarios);
String respStr = EntityUtils.toString(resp.getEntity());
JSONArray respJSON = new JSONArray(respStr);
this.resul = true;
}
catch(Exception ex)
{
Log.e("ServicioRest","Error!", ex);
this.resul = false;
}
}
public boolean getResul()
{
return this.resul;
}
protected void onProgressUpdate(String... progress) {
Log.d("ANDRO_ASYNC",progress[0]);
//mProgressDialog.setProgress(Integer.parseInt(progress[0]));
}
#Override
protected void onPostExecute(Void unused) {
//mProgressDialog.dismiss();
}
}
//calling the AsyncTask from the activity:
CargaDatosRest CallRest = new CargaDatosRest(this.getApplicationContext());
CallRest.execute();
Log.v("WebService", "Just trying "+arest.getResul());