obaro / simplewebapi Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
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
}
I neither get a response nor do I get any progressBar movement.
package com.example.shreyanshu.sample;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
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;
TextView responseView;
ProgressBar progressBar;
static final String API_KEY = "key added";
static final String API_URL = " https://api.fullcontact.com/v2/person.json?";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
emailText = (EditText) findViewById(R.id.emailText);
responseView = (TextView) findViewById(R.id.responseView);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
Button queryButton = (Button) findViewById(R.id.queryButton);
queryButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
new RetrieveFeedTask().execute();
}
});
}
class RetrieveFeedTask extends AsyncTask<Void, Void, String> {
private Exception exception;
String email;
public RetrieveFeedTask() {
this.email = emailText.getText().toString();
}
protected void OnPreExecute() {
progressBar.setVisibility(View.VISIBLE);
responseView.setText("About to start");
}
protected String doInBackground(Void...urls) {
try {
URL url = new URL(API_URL + "email=" + email + "&apiKey=" + API_KEY);
Log.e("URL", url.toString());
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 onPostExcecute(String response) {
if (response == null) {
response = "There was an ERROR";
}
progressBar.setVisibility(View.GONE);
Log.e("INFO", response);
responseView.setText(response);
}
}
}
requires com.android.application plugin to build
Obaro,
Would you consider adding a license to your code such as MIT license to allow others to use it? That would also probably get more credit for you when people do use your code. There's a short explanation of how to do that here, https://github.com/blog/1530-choosing-an-open-source-license
In particular, I am interested in using part of your SimpleWebAPI as starter code for an Android app and possibly in a YouTube video, but need a license to use it.
Many thanks,
Joe James
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.