com.netmera.facebook
Class Util

java.lang.Object
  extended by com.netmera.facebook.Util

public final class Util
extends java.lang.Object

Utility class supporting the Facebook Object.


Constructor Summary
Util()
           
 
Method Summary
static void clearCookies(android.content.Context context)
           
static android.os.Bundle decodeUrl(java.lang.String s)
           
static java.lang.String encodePostBody(android.os.Bundle parameters, java.lang.String boundary)
          Generate the multi-part post body providing the parameters and boundary string
static java.lang.String encodeUrl(android.os.Bundle parameters)
           
static void logd(java.lang.String tag, java.lang.String msg)
          A proxy for Log.d api that kills log messages in release build.
static java.lang.String openUrl(java.lang.String url, java.lang.String method, android.os.Bundle params)
          Connect to an HTTP URL and return the response as a string.
static org.json.JSONObject parseJson(java.lang.String response)
          Parse a server response into a JSON Object.
static android.os.Bundle parseUrl(java.lang.String url)
          Parse a URL query and fragment parameters into a key-value bundle.
static void showAlert(android.content.Context context, java.lang.String title, java.lang.String text)
          Display a simple alert dialog with the given text and title.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

encodePostBody

public static java.lang.String encodePostBody(android.os.Bundle parameters,
                                              java.lang.String boundary)
Generate the multi-part post body providing the parameters and boundary string

Parameters:
parameters - the parameters need to be posted
boundary - the random string as boundary
Returns:
a string of the post body

encodeUrl

public static java.lang.String encodeUrl(android.os.Bundle parameters)

decodeUrl

public static android.os.Bundle decodeUrl(java.lang.String s)

parseUrl

public static android.os.Bundle parseUrl(java.lang.String url)
Parse a URL query and fragment parameters into a key-value bundle.

Parameters:
url - the URL to parse
Returns:
a dictionary bundle of keys and values

openUrl

public static java.lang.String openUrl(java.lang.String url,
                                       java.lang.String method,
                                       android.os.Bundle params)
                                throws java.net.MalformedURLException,
                                       java.io.IOException
Connect to an HTTP URL and return the response as a string. Note that the HTTP method override is used on non-GET requests. (i.e. requests are made as "POST" with method specified in the body).

Parameters:
url - - the resource to open: must be a welformed URL
method - - the HTTP method to use ("GET", "POST", etc.)
params - - the query parameter for the URL (e.g. access_token=foo)
Returns:
the URL contents as a String
Throws:
java.net.MalformedURLException - - if the URL format is invalid
java.io.IOException - - if a network problem occurs

clearCookies

public static void clearCookies(android.content.Context context)

parseJson

public static org.json.JSONObject parseJson(java.lang.String response)
                                     throws org.json.JSONException,
                                            FacebookError
Parse a server response into a JSON Object. This is a basic implementation using org.json.JSONObject representation. More sophisticated applications may wish to do their own parsing. The parsed JSON is checked for a variety of error fields and a FacebookException is thrown if an error condition is set, populated with the error message and error type or code if available.

Parameters:
response - - string representation of the response
Returns:
the response as a JSON Object
Throws:
org.json.JSONException - - if the response is not valid JSON
FacebookError - - if an error condition is set

showAlert

public static void showAlert(android.content.Context context,
                             java.lang.String title,
                             java.lang.String text)
Display a simple alert dialog with the given text and title.

Parameters:
context - Android context in which the dialog should be displayed
title - Alert dialog title
text - Alert dialog message

logd

public static void logd(java.lang.String tag,
                        java.lang.String msg)
A proxy for Log.d api that kills log messages in release build. It not recommended to send sensitive information to log output in shipping apps.

Parameters:
tag -
msg -