воскресенье, 11 декабря 2011 г.

Some good tips if you have problems with the emulator

Some tips about the ICS emulator

1) Don't expect it to run well on any machine with less than 3GB of RAM. It can be done, but don't rely on it :).

2) There is a list of know issues in the emulator at http://tools.android.com/release/knownissues (from @ediTLJ on twitter)

3) Increase the default RAM for your AVDs to 1024MB (yup, 1GB)

4) If the emulator has crashed try deleting the AVD you used. If you're told the AVD is in use then you'll need to create a new AVD.

5) If you've hit problems with Snapshot set to Enabled on the AVD then turn it off.

6) Try setting the Max VM application heap size to 40MB or more (from+Reuben Scratton )

7) If your first boot appears to lock up it could be your contacts database. Try exiting the emulator and re-starting it (from +Reuben Scratton )

8) The screen resolution for the Nexus Prime is listed as WXGA720 in the AVD settings.

9) If you want to see what ICS will look like on a tablet use WSVGA or WXGA800 as the resolution.

10) The software buttons for Home, Back, etc. don't appear to be in the ICS image for some resolutions. Resolutions known to support the soft buttons are WSVGA and WXGA800.

четверг, 22 сентября 2011 г.

Android snippet: Check if the device is connected to the internet

Just a quick function to make your live easier
How to check if the device that runs your application has an active internet connection
Here is the function:
public static boolean isOnline(Context context) {
     ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
     NetworkInfo netInfo = cm.getActiveNetworkInfo();
     if (netInfo != null && netInfo.isAvailable() && netInfo.isConnected()) {
         return true;
     }
     return false;
}
Also You must add the INTERNET and ACCESS_NETWORK_STATE permissions to Your application
<uses-permission android:name="android.permission.INTERNET"  />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

четверг, 21 июля 2011 г.

Integrating twitter into android app


Many Android developers ask how to start the default twitter client from their application. Which Intent should you use?

It is often advised to send an Intent with ACTION_SEND. However, many programs will fire up: Gmail, SMS send, dropbox, twitter clients, MMS Send, flickr send, etc. This is too broad.

On the other hand, some people advise to filter on the MIME type application/twitter. But this is too restrictive: very few clients will recognize this unofficial/non-standardized MIME type (twidroid is among them, but HTC default client is not).

So, You can:

понедельник, 27 июня 2011 г.

Speed up your eclipse as a super fast IDE

Follow these 5 steps to speed up your eclipse as a super fast IDE , it works for 32 & 64 bit version eclipse/jdk.

1. Disable antivirus software, or add your jdk & eclipse & workspace & other related folder to white list in your antivirus software


2. Disable unecessary validations and startup action in eclipse reference.

пятница, 24 июня 2011 г.

четверг, 23 июня 2011 г.

Android: Use the ViewHolder

This is going to be a quick hit blog post about the Android "ViewHolder" pattern. To really make use of the ViewHolder with Android you do need to know what theListView widget is (a helper for managing views of lists), and that ListViews and generally backed byAdapters (adapters provide data for lists and build views for said data, they can be made from lists of stuff in files, or from in memory arrays, or from databases, and so on).

We will look at the code, complete with ViewHolder, coming up. First a bit more background.

среда, 22 июня 2011 г.

Asynchronous Lazy Loading and Caching of ListView Images

I am using a custom CursorAdapter for a ListView to display some images and captions associated with those images. I am getting the images from the Internet.
The implementation produced significant lag in the UI when scrolling through items. This is because the getView() method of a ListView adapter can be called one or more times each time a ListView item comes into view – we are given no guarantees on when or how this method will be called. Therefore, downloading images within getView() was extremely inefficient, as each image was being downloaded by the UI thread as the ListView item came into view, and was usually downloaded repeatedly after that.

Today I’ll refactor my app to add asynchronous lazy loading and caching of images. Some of the code included has been based on the excellent demonstration provided by Github user thest1. Through this example, I’ll demonstrate asynchronous operations in Android, using local storage for caching data, ViewHolders, and a few other advanced techniques for optimizing app performance.


Since all(downloading images) of this is happening on the UI thread, massive UI lag resulted, which would create a poor user experience for a production app. The root problems are:

  1. Images are being downloaded from the UI thread
  2. Images are being downloaded many, many more times than they need to be, since getView() is called as often as Android feels like calling it

So, what can we do?