Graph and REST
1. Use Graph
/ALBUM_ID/photos
This way needs album id to upload a photo within a album.
Bundle params = new Bundle();
Uri uri = (from somewhere)
byte[] data = null;
InputStream is = mContext.getContentResolver().openInputStream(uri);
data = new byte[is.available()];
is.read(data);
if (data != null) {
params.putString("message", "test");
params.putByteArray("source", data);
String response = Facebook.request(ALBUM_ID/photos, params, "POST");
}
2. Use REST
photos.upload
This doesn't need a album id, instead it creates a album with your application name if there doesn't exist one.
Bundle params = new Bundle();
Uri uri = (from somewhere)
byte[] data = null;
InputStream is = mContext.getContentResolver().openInputStream(uri);
data = new byte[is.available()];
is.read(data);
if (data != null) {
params.putString("method", "photos.upload");
params.putByteArray("picture", data);
String response = Facebook.request(null, params, "POST");
}
Sunday, August 14, 2011
Tuesday, July 12, 2011
Android: How to encode an URL path
Reference page
http://developer.android.com/reference/java/net/URLEncoder.html
Input (Bundle):
Bundle parameters;
Output (Encoded path):
String result = null;
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String key : parameters.keySet()) {
if (first) {
first = false;
}
else {
sb.append("&");
}
sb.append(URLEncoder.encode(key) + "=" +
URLEncoder.encode(parameters.getString(key)));
}
result = sb.toString();
http://developer.android.com/reference/java/net/URLEncoder.html
Input (Bundle):
Bundle parameters;
Output (Encoded path):
String result = null;
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String key : parameters.keySet()) {
if (first) {
first = false;
}
else {
sb.append("&");
}
sb.append(URLEncoder.encode(key) + "=" +
URLEncoder.encode(parameters.getString(key)));
}
result = sb.toString();
Thursday, July 7, 2011
android-protips-location & A Deep Dive into Location
These articles are full tips and experience. Read this to improve you Android technic.
android-protips-location
http://code.google.com/p/android-protips-location/
A Deep Dive Into Location
http://android-developers.blogspot.com/2011/06/deep-dive-into-location.html
http://blog.radioactiveyak.com/2011/06/deep-dive-into-location-part-2-being.html
android-protips-location
http://code.google.com/p/android-protips-location/
A Deep Dive Into Location
http://android-developers.blogspot.com/2011/06/deep-dive-into-location.html
http://blog.radioactiveyak.com/2011/06/deep-dive-into-location-part-2-being.html
Monday, July 4, 2011
Uri schemes for Android
Android provides 3 types of Uri for pointing a content.
SCHEME_ANDROID_RESOURCE
SCHEME_CONTENT
SCHEME_FILE
Developer has to deal with these schemes to point a content out when transferring via an Uri.
SCHEME_ANDROID_RESOURCE
SCHEME_CONTENT
SCHEME_FILE
Developer has to deal with these schemes to point a content out when transferring via an Uri.
Thursday, June 30, 2011
Instant Upload on Google+
I am using Google+, its a complete socail environment.
I love the circles (just imagine t a movie "Litte Fockers" , Robert always says the "circle")
Now you can choose who can be in your circle!
As title I am talking the Instant Upload.
It will observe your pictures taken by camera and upload it if you ckeck the option in settings.
You can also choose upload via mobile network or wifi for each photos and videos.
Be noticed, it upload to instant album only.
Before this, HTC Sense (like Chacha & Salsa) has this function named "Auto Backup" and much well design.
Now HTC Sense supports two two Services as Facebook and Flickr.
Each service you can select a default album you want to upload.
Besides Instant Upload and only upload via Wifi, HTC Sense supports "Scheduler Upload".
You could set a daily scheduler to upload your photos on time.
This allows you upload photos when you are sleeping while the phone is charged.
It will not influence your internet speed, phone performance, and don't worry about battery dead.
If you have any suggestions on Auto Backup, please give me some feedback.
I'll improve it.
Thanks.
Sanhom
Subscribe to:
Posts (Atom)