I'm trying to send a JSON object and an associated thumbnail to Google+. But I'm having trouble getting it to work. I get, for instance, the response:
05-30 22:38:16.819: E/AndroidRuntime(11643): FATAL EXCEPTION: main
05-30 22:38:16.819: E/AndroidRuntime(11643): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=application/json flg=0x80000 pkg=com.google.android.apps.plus (has extras) }
05-30 22:38:16.819: E/AndroidRuntime(11643): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
which tells me the Google+ libraries aren't finding the proper way to handle the "application/json
" MIME type. My code (relevant part) runs like this (I obtained most of it from the Google+ examples):
PlusShare.Builder builder = new PlusShare.Builder(this, plusClient);
// Set call-to-action metadata.
builder.addCallToAction("VIEW_ITEM", callToActionUrl, callToActionDeepLinkId);
File thumbnailFile = generateThumbnail();
builder.setStream(Uri.fromFile(outputJSON()));
builder.setType("application/json");
thumbnailFile!=null?Uri.fromFile(thumbnailFile):null);
and if I avoid setting the stream to the JSON type, it seems to be working all right. The JSON I'm generating is like this:
{"INSTRUMENTS":
[{"MINOR":false,"CHANNEL":0,"MAJOR":false,"HIGH_RANGE":-8012206,
"PROGRAM":1,"MAX_KEY":70,"NOTE_LENGTH":150,"LOW_RANGE":-16217748,
"MIN_VELOCITY":60,"MIN_KEY":40},
{"MINOR":false,"CHANNEL":2,"MAJOR":true,"HIGH_RANGE":-2790500,
"PROGRAM":8,"MAX_KEY":90,"NOTE_LENGTH":150,"LOW_RANGE":-12114977,
"MIN_VELOCITY":60,"MIN_KEY":70}]}
I've seen different APIs which tell how to send JSON objects like these with Bitmaps and what-have-you but the Android API documentations is slightly... sparse. Anyone out there who knows how I can manage to do the same stuff in Android?
Ideally, once done correctly, the post should contain:
- A thumbprint of an image
- JSON data which, when an user clicks on the post from an Android device, will be used by my app through deep-linking
- Text/title written by the user