i try to push a timeline card to the Glass from my android application. i use this code:
String BASE_URL = "https://www.googleapis.com/upload/mirror/v1/";
try {
final HttpPost request = new HttpPost();
request.setURI(new URI(BASE_URL + "timeline"));
request.addHeader("Authorization", String.format("Bearer %s", token));
request.addHeader("Content-Type", "application/json");
request.setEntity(new StringEntity(json.toString()));
// Execute the request on a background thread
mThreadPool.execute(new Runnable() {
@Override
public void run() {
try {
final HttpResponse response = mClient.execute(request);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
mHandler.post(new Runnable() {
@Override
public void run() {
callback.onSuccess(response);
}
});
} else {
mHandler.post(new Runnable() {
@Override
public void run() {
callback.onFailure(response, null);
}
});
}
} catch (final IOException e) {
mHandler.post(new Runnable() {
@Override
public void run() {
callback.onFailure(null, e);
}
});
}
}
});
} catch (UnsupportedEncodingException e) {
// Note: This should never happen
} catch (URISyntaxException e) {
// Note: This should never happen
}
the json is like this :
{"notification":{"level":"DEFAULT"},"text":"Pizza and spaghetti"}
but the service respond with an error :
"error": {
"errors": [
{
"domain": "global",
"reason": "badContent",
"message": "Media type 'application/json' is not supported. Valid media types: [image/*, audio/*, video/*]"
}
],
"code": 400,
"message": "Media type 'application/json' is not supported. Valid media types: [image/*, audio/*, video/*]"
}
}
i follow the code from here: https://github.com/twaddington/mirror-quickstart-android
any idea?
Ps. there is another way to push a timeline card from an android application to the google glass?
Thanks