mardi 12 juillet 2011

Intégration Bitly Shorten & android App

Bitly is a service among other found on the web to create shortcuts link.

 In my case I use a lot to shorten links to list items from a parsing an RSS feed. character in order to win the gold for sharing these links on twitter.

The integration of this service and guaranteed through a class already developed this need by service team Bitly "Finn J Johnsen Copyright 2010", you will download this class gifts and include the sources of your project .

The source code and available on Googlecode Class (See Link)

Class "BitlyAndroid" provides you with the method "getShortUrl (String urlToShorten)" as the shortcut String return type. Httpclient through.

In just instantiate the class through its constructor with your "API key" and "Login" as parameters for authentication service and the name of the method "getShortUrl"





public String testGetShortUrlAsShouldBeUsed(String urlToShorten) {
  BitlyAndroid bitly = new BitlyAndroid(Util.LOGIN, Util.APIKEY);
  String shortUrl;
  try {
   shortUrl = bitly.getShortUrl(urlToShorten);
   return shortUrl;
  } catch (Exception e) {
   e.printStackTrace();
   return null;
  }
 }





vendredi 1 juillet 2011

Parsing RSS et l'affichage des caractères

Un des problèmes que j'ai rencontré  l'ors de l'affichage de la description d'un item après un évent comme
Onclick Que y a  des  caractère qui  s'affiche pas correctement dans Mon  webView .
Pour remédier a ce problème il faut juste utiliser la méthode  " loadDataWithBaseURL" comme suite :

WebView objetview = (WebView) v.findViewById(R.id.eltWebView);

String mapage = rssItem.get(position).getDescription()

objetview.loadDataWithBaseURL(null, mapage, "text/html", "UTF-8",null);