Open SameerKhan1406 opened 8 years ago
Hi SameerKhan,
What API are you calling?
Send sample code, and I'll assist if I can
On Sat, Oct 15, 2016 at 2:36 PM, SameerKhan1406 notifications@github.com wrote:
I am passing two values instead one and using my api url since it accepts two parameter.
Just tell me how to api which i created i have my url and it accepts two parameter and return response in Json which i want to print { Status=1 message"dewegow523yrinc" any random everytime i am calling }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/obaro/SimpleWebAPI/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/ADxkCnz1mhc-j0QPf_ieOqFG8Ns-KLz5ks5q0NbRgaJpZM4KXtVc .
From, Obaro
Thank you for asking. I am terrified since Saturday and i am beginner in android Please resolve this Find below detail for API :
URL : http://192.168.0.19/monika/slim_prj/public/code
Request Parameter (in POST)
Response (in JSON) -
{ "status": 1, "message": "qYNoQBImXRhOMety" }
Have you started working on how to do this thing?
`This is my code`` package com.medmainfomatix.myapplication1;
import android.os.AsyncTask; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.TextView;
import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL;
public class MainActivity extends AppCompatActivity {
EditText emailText; EditText emailText1; TextView responseView; ProgressBar progressBar;
static final String API_URL = "http://192.168.0.19/monika/slim_prj/public/code/";
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
responseView = (TextView) findViewById(R.id.responseView); emailText = (EditText) findViewById(R.id.emailText); emailText1= (EditText) findViewById(R.id.emailText1);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
Button queryButton = (Button) findViewById(R.id.queryButton); queryButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new RetrieveFeedTask().execute(); } }); }
class RetrieveFeedTask extends AsyncTask<Void, Void, String> {
private Exception exception; String mac_address = emailText.getText().toString(); String key= emailText1.getText().toString();
protected void onPreExecute() { progressBar.setVisibility(View.VISIBLE); responseView.setText(""); }
protected String doInBackground(Void... urls) {
// Do some validation here
try { URL url = new URL(API_URL + "mac_address=" + mac_address + "Key=" + key); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); try { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); StringBuilder stringBuilder = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line).append("\n"); } bufferedReader.close(); return stringBuilder.toString(); } finally{ urlConnection.disconnect(); } } catch(Exception e) { Log.e("ERROR", e.getMessage(), e); return null; } }
protected void onPostExecute(String response) { if(response == null) { response = "THERE WAS AN ERROR"; } progressBar.setVisibility(View.GONE); Log.i("INFO", response); responseView.setText(response); // TODO: check this.exception // TODO: do something with the feed
// try { // JSONObject object = (JSONObject) new JSONTokener(response).nextValue(); // String requestID = object.getString("requestId"); // int likelihood = object.getInt("likelihood"); // JSONArray photos = object.getJSONArray("photos"); // . // . // . // . // } catch (JSONException e) { // e.printStackTrace(); // } } } }
How about you post on stackoverflow. Your question and the solution would then be available to others who run into the same issue.
Let me know when you've made a post, so I'll answer it
I already did that go to the link below : http://stackoverflow.com/questions/40071964/android-i-need-to-call-web-api
I am passing two values instead one and using my api url since it accepts two parameter.
Just tell me how to api which i created i have my url and it accepts two parameter and return response in Json which i want to print { Status=1 message"dewegow523yrinc" any random everytime i am calling }