How To Implement an ImageGetter in Android

How To Implement an ImageGetter in Android

Article by Walter M. Soto

How To Implement Html.fromHtml With ImageGetter in Android

You have an Android App that just fetched HTML content from the web to be displayed on a TextView. The first thing we do is to use Html.fromHtml() method; however, you soon realize that this method replaces all images with generic placeholders (besides not supporting all HTML tags). The good news is that this method does support ways of handling images (and other tags but this tutorial is just for images).Implementing a ImageGetter is straight and simple; you pass an ImageGetter object to be use to fetch the images that later will be use to fill the placeholders. In order to fetch the images the ImageGetter object must implement the getDrawable method. The getDrawable method must return the Drawable object that will fill the placeholder; but, if null is returned the generic image placeholder will be used instead (see implementation below).

String s = Html.fromHtml(htmlContent, new ImageGetter() {

@Override public Drawable getDrawable(String source) { return null; } } ,null);

Implementing a ImageGetter is straight and simple; you pass an ImageGetter object to be use to fetch the images. The way you fetch the images will vary depending on your application needs; so for this example I will fetch the images directly to an InputStream object (sometimes the best way could be saving them to a folder in the SD card).

Fetch Methodpublic InputStream imageFetch(String source)throws MalformedURLException,IOException {

URL url = new URL(source); Object o = url.getContent(); InputStream content = (InputStream)o; // add delay here (see comment at the end) return content;

}

Fully Implemented MethodSpannableStringBuilder s = (SpannableStringBuilder)Html.fromHtml(htmlContent, new ImageGetter() { @Override public Drawable getDrawable(String source) { Drawable d = null; try { InputStream src = imageFetch(source); d = Drawable.createFromStream(src, “src”); if(d != null){d.setBounds(0,0,(d.getIntrinsicWidth(),d.getIntrinsicHeight()); }} catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }

return d; }

},null);

TextView t = (TextView)findViewById(R.id.textOutput);t.setText(s);

One thing to consider is big images may need more time to download so depending on the connection you app may not be able to load all images. Some people work around this by saving the images on the SD card; however, I have gotten around this issue by running this method asynchronously while putting a slight delay on the imageFetch function (right before returning the content).

Additional revisions to this article and color coded source code can be found at Here

Software Development tips for .NET, JavaScript, and Mobile Platforms. Visit http://www.developercaster.com for more information.










Incoming search terms:

  • powered by myBB small business merchant accounts
  • android image placeholder
  • android imagegetter tutorial

Quick Tips to Help You on Your Android Phone

Quick Tips to Help You on Your Android Phone

Using the is a good experience for many. It allows them to access many features and applications.Furthermore; you can get access to the android marketplace which has thousands of applications which one can instantly download. This is due to the access of the android operating system that was developed by Google. In many cases, the android gadget performs many of the applications that would be ordinarily performed by a personal computer. This has removed the need for one to carry a laptop all over the place. One advantage of the android phones is access to the internet which is enabled by the internet browser. The device comes with a preinstalled Google chrome browser but you can download other browsers such as mozilla firefox and Opera Mini.

]]>

There are a few tips which you can use in order to enhance your internet experience. For instance, when you hold down the Back button in the browser, this will bring up a history of all the pages that have been visited recently. You can also take a shortcut when you need to zoom. You can double tap in the browser in order to achieve this effect. In many android devices, you can zoom by simply pinching the screen with two fingers. This is popularly known as multi-touch. This same shortcut can also be used when one is in the image gallery.

When you need to copy text in the internet browser, all you have to do is to hold and then select copy text from the resulting menu that will pop up. If you have a recent android version such , there will be two select marks that will be shown when you tap and hold. You can then drag the marks around the text that you have selected. There will be three icons which will be displayed. There will be a pages icon which will in effect copy the text that has been selected. In addition, there will be a green upwards arrow which will let you share the text. There is also a magnifying glass which will assist you to look up the selected text in the Wikipedia website. Alternatively, it can translate the text for you and also look for its meaning in the dictionary.

If you need to share the content on url, then it is very simple. All you have to do is to press the address bar and in an instant you will share the contents of the URL with your friends and colleagues. In case save an image on the internet, all you have to do is to long press an image. You can then share the image in social networking sites or via email and MMS. It also possible for you to locate addresses of places even if they are not links. All you have to do is to tap the addresses and there will be an option for the image to be shown in Google maps. This also applies to phone numbers. You will also get the option of dialing the number.

As you can see, are actually very easy for you to access many features on the browser by using very basic shortcuts. The trick is to try the shortcuts and it will come naturally.

As you can see, android cell phones are actually very easy for you to access many features on the browser by using very basic shortcuts. The trick is to try the shortcuts and it will come naturally.

Incoming search terms:

  • powered by SMF 2 0 small handheld magnifying mirror
  • android phone help tips
  • android shortcuts tips
  • quick tips android 2 3
  • samsung galaxy yp-mb2
  • two fingers zoom using Android
  • zoom with two fingers using Android

Tips for prolong the 4G Android smartphone battery life

Tips for prolong the 4G Android smartphone battery life

I have a 4G Android smartphone that blows through the battery in less than a day! Any tips for extending the battery life?

The Android smartphone platform has gone from an unrefined newcomer to the #1 platform in a relatively short period of time. The most recent Comscore rankings showed that Google’s Android is used by 41.8% of smartphone subscribers while Apple’s iPhone IOS was at 27% and RIM (Blackberry) has slid down to 21.7%. (A year ago, RIM’s Blackberry was #1, with Apple second and Android 3rd.)

In order to compete with the Blackberry & iPhone dynasties, Google and the handset manufacturers had to create alternatives that were compelling enough to be considered an option, which they clearly have done.

Bigger screens, 4G connectivity, built-in hotspots and a slew of other differences have certainly played a big role in luring users away, but the tradeoff for all these great features can be diminished battery life if you’re not careful.

It’s important that you really think about how you use your phone to know which features aren’t really necessary to have running in order to extend the battery life.

]]>

Android device options vary by manufacturer and version of the OS they have installed, but there are some basic battery extension tips that apply to all smartphones.

The screen brightness is one of the biggest battery killers, so make sure you lower the levels as low as you can reasonably set it for a big boost.

Location services are very handy, but having the GPS update your location as you move around can also drain the battery, so turn it off unless you need it (if an app needs it, you’ll be alerted). 

One of the silly features that Android phones offer is ‘Live Wallpaper’ which isn’t a huge drain on the battery, but it serves no real purpose, so stick to a static background.

If you search the Internet for battery saving tips, many will suggest that you install a ‘task killer’ app so you can shut down processes that are running in the background, but I’m not sure that it’s the best idea for everyone.

Tech savvy users who understand what they are looking at can effectively use task killers to extend battery life, but I’ve seen many non-technical users randomly turn things off that they don’t recognize and disable critical functions of the phone.

Another potential drain on the battery is when your cellular signal is weak as the phone is constantly scanning for a better signal. If you are in a weak signal area and have wi-fi available, put the phone in Airplane mode and connect via wi-fi.

4G speeds are amazing, especially on Verizon’s LTE network, but it’s also going to consume more juice so check to see if an extended battery option exists for your phone if you are an avid surfer on a 4G network.

The built-in hotspot feature is also pretty handy when you have other devices that you’d like to connect to the Internet, but you will also watch your battery levels drop right before your eyes.

Try to plug the phone into a wall socket whenever you plan on using it as a hotspot if at all possible.

Some of the newer handsets such as Motorola’s Droid Bionic have beefed up batteries and newer power management tools built-in that help you understand exactly which process is using up your battery power.

Android devices update the operating system regularly, so be sure to look at your setting options from time-to-time to see if any new battery management options get added to your phone.

Read More

http://www.bestlaptopbattery.co.uk - We specialize in laptop battery and laptop ac adapter. Give your laptop a new life with higher capacity battery. 

Dell d830 Battery , Sony vgp-bps8 battery , Hp pavilion dv6 battery on sales!!

Incoming search terms:

  • battery app october 2011
  • best smartphone batter life october 2011
  • android device with best battery life
  • phone with the best battery life october 2011
  • how to prolong your android battery life
  • how to prolong smartphone battery
  • best smartphone battery life
  • best andriod apps for battery life oct 2011
  • android phone with best battery life 2011
  • smartphones android battery life 2011

Android 2.2.1 Update – New Android Gmail and more

Android 2.2.1 Update – New Android Gmail and more Android 2.2.1 Update was just released and I got mine for my original Droid phone on Dec 10, 2010. It is still called Froyo, but has some very noticeable enhancements. The new Android Gmail program is my favorite.

Big changes to Droid Gmail / Android Gmail… whatever you call it. Backlinks . Herbal Health Remedies . The things that bugged me most are now fixed. I can do most everything I need now right from my Android 2.2.1 enhanced Droid phone.

Read on to see what changed… and how you can get the new Gmail even if your phone has not received the Android 2.2.1 system update yet. (disclaimer, your phone must be running at least Android 2.2 to get and use the new Mobile Gmail App) ]]>
Here is a list of items that have changed since Froyo 2.2.1 came onto the scene:

* New Twitter Widget
* New Amazon Widget
* New News & Weather Widget
* Improvements to Microsoft Exchange ActiveSync
* *** Improved GMAIL for Android Phones ***
* Priority Inbox added to Mobile Gmail
* More Reply options in more places
* Ability to reply “inline”

The stuff listed here are what we go into in more detail on our website, but knowing which ones to look for could be helpful to guide you in discovering what’s new in 2.2.1.

You get the benefit of our struggle to figure it all out, and get to learn about it the easy way. We give you free text and video ver. of our training efforts. Linux Software . Find out which format works best for your learning style on our website.

A special note: Our text versions always contain a little more information than the video tutorials do because we try to keep videos as short as practical. We have quick text tip articles as well.

Get the most our of your Droid Phone the easy way via UseMyDroid.com.

Get more out of your Droid Phone. Watch or read our video or text tutorials all about your Droid phone.

UseMyDroid provides crisp, clean, easy to follow, easy to learn tutorials to help you get the most from your Droid Phone. UseMyDroid.com

Incoming search terms:

  • android gmail widget
  • android gmail update
  • new gmail count widget android
  • gmail android update
  • android tips
  • froyo gmail widget
  • android new gmail flash
  • gmail count widget froyo
  • gmail update
  • gmail widget for android 2 2