Upload activity to Strava with my own Android app

1,133 views
Skip to first unread message

oscar.c...@gmail.com

unread,
Feb 25, 2014, 2:17:56 AM2/25/14
to strav...@googlegroups.com
Hi,

I have created an Android app that generate a gpx file. I have upload that gpx file to Strava manually. It's work!!

Now, I want to modify mi app in order to upload automatically the gpx file to Strava. I have readed the documentation but I don't understand how do it. Somebody can help me? I wish see an example of Android code for this task.

Regards.

oscar.c...@gmail.com

unread,
Feb 27, 2014, 6:01:25 AM2/27/14
to strav...@googlegroups.com
This is my code, but it doesn't work:

   private void uploadStrava() {
   
        // Create HttpClient and Post Header
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("https://www.strava.com/api/v3/uploads");
   
        try {
           
            // Add new dates
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
           
            nameValuePairs.add(new BasicNameValuePair("id", "171335"));
            nameValuePairs.add(new BasicNameValuePair("file", fileName));
            nameValuePairs.add(new BasicNameValuePair("data_type", "gpx"));

            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
   
            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);
            Toast.makeText(getApplicationContext(), response.getAllHeaders().toString(), Toast.LENGTH_LONG).show();
           
        } catch (ClientProtocolException e) {
            Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
        } catch (IOException e) {
            Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
        }   
    }

Fulvio Brosio

unread,
Mar 1, 2014, 1:18:55 PM3/1/14
to strav...@googlegroups.com
With the new Strava api you shall:
1) Register your app and get a client_id and secret code
2) Connect to the Strava website to allow your application to access your (or the app user's) data: you will get a code
3) With this code, you need to post a request to have an access token
4) Finally, with the access token, you can upload your ride

Your snippet just show the upload code: did you completed the previous steps?

oscar.c...@gmail.com

unread,
Mar 1, 2014, 1:23:01 PM3/1/14
to strav...@googlegroups.com
No, I didn't. I'm going to do it now. Thanks so much.

Shane Elliott

unread,
Dec 23, 2014, 5:49:06 AM12/23/14
to strav...@googlegroups.com

Hi 

Did you manage to get the code working? I am trying to do the same thing. Is there any chance you could send me your code.

Thanks!

Vladimir Bjelakovic

unread,
Jun 19, 2015, 10:14:21 AM6/19/15
to strav...@googlegroups.com
Any progress?

Vinay Vanama

unread,
Jan 3, 2016, 1:58:32 PM1/3/16
to Strava API
Hi,

I'm trying to access the strava api but unfortunately I dont know how to connect with the strava

If you have any code snippet in android platform plz share with me...

Thanks
Reply all
Reply to author
Forward
0 new messages