Created
June 13, 2013 15:36
-
-
Save iraSenthil/5774698 to your computer and use it in GitHub Desktop.
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
| private void getAccessToken(String authCode) { | |
| String accessTokenUrl = "https://runkeeper.com/apps/token?grant_type=authorization_code&code=%s&client_id=%s&client_secret=%s&redirect_uri=%s"; | |
| final String finalUrl = String.format(accessTokenUrl, authCode, CLIENT_ID, CLIENT_SECRET, CALLBACK_URL); | |
| Thread networkThread = new Thread(new Runnable() { | |
| @Override | |
| public void run() { | |
| try { | |
| HttpClient client = new DefaultHttpClient(); | |
| HttpPost post = new HttpPost(finalUrl); | |
| HttpResponse response = client.execute(post); | |
| String jsonString = EntityUtils.toString(response.getEntity()); | |
| final JSONObject json = new JSONObject(jsonString); | |
| String accessToken = json.getString("access_token"); | |
| getTotalDistance(accessToken); | |
| } catch (Exception e) { | |
| displayToast("Exception occured:("); | |
| e.printStackTrace(); | |
| resetUi(); | |
| } | |
| } | |
| }); | |
| networkThread.start(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment