-
-
Save AndreiD/20c371f463058a4fd0cc1e2d07347b13 to your computer and use it in GitHub Desktop.
dsfa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mex.integrationapp; | |
import android.os.CountDownTimer; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import com.squareup.okhttp.Call; | |
import com.squareup.okhttp.Callback; | |
import com.squareup.okhttp.OkHttpClient; | |
import com.squareup.okhttp.Request; | |
import com.squareup.okhttp.Response; | |
import java.io.IOException; | |
import gotomobile.Gotomobile; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
new RunServerTask().execute(); | |
new CountDownTimer(1000, 1000) { | |
@Override | |
public void onTick(long millisUntilFinished) { | |
} | |
@Override | |
public void onFinish() { | |
OkHttpClient client = new OkHttpClient(); | |
Request request = new Request.Builder() | |
.url("http://localhost:8080/welcome?firstname=Me&lastname=You") | |
.build(); | |
client.newCall(request).enqueue(new Callback() { | |
@Override | |
public void onFailure(Request request, IOException e) { | |
e.printStackTrace(); | |
} | |
@Override | |
public void onResponse(Response response) throws IOException { | |
if (!response.isSuccessful()) { | |
throw new IOException("Unexpected code " + response); | |
} | |
Log.d("> GOT >", response.body().string()); | |
} | |
}); | |
} | |
}.start(); | |
} | |
static class RunServerTask extends android.os.AsyncTask { | |
@Override | |
protected Object doInBackground(Object[] objects) { | |
Gotomobile.runServer(); | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment