воскресенье, 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.

четверг, 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?

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

Using the Contact Picker. Getting phone and send sms

How to get email or phone from contacts and use it in your app?
This tutorial will start out simple, but then we’ll get in to some of the technical details of using Contacts with the ContactsContract class, which was introduced in API Level 5.

Step 1: Launching the Contact Picker

import android.provider.ContactsContract.Contacts;  
import android.provider.ContactsContract.CommonDataKinds.Phone;  

private static final int CONTACT_PICKER_RESULT = 1001;  
  
public void doLaunchContactPicker(View view) {  
    Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,  
            Contacts.CONTENT_URI);  
    startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);  
}

Once launched, the contacts picker in your application will look something like this:

пятница, 29 апреля 2011 г.

воскресенье, 3 апреля 2011 г.

Simon Sinek: How great leaders inspire action | Video on TED.com

Simon Sinek: How great leaders inspire action | Video on TED.com
Замечательная лекция с не менее замечательными примерами, в которой показано, что нужно все начинать с вопроса Зачем?, а уже потом подходить к вопросам Как? и Что?

пятница, 1 апреля 2011 г.

How to show/hide the Android Soft Keyboard

If You need to show or to hide a virtual (soft) keyboard in Android app:
To hide:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
This will force the keyboard to be hidden in all situations. In some cases you will want to pass in InputMethodManager.HIDE_IMPLICIT_ONLY as the second parameter to ensure you only hide the keyboard when the user didn't explicitly force it to appear (by holding down menu).

To show:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(myEditText, 0);

понедельник, 7 марта 2011 г.

Android Gingerbread Easter Egg

For the Android device owners out there who have upgraded to Gingerbread, have you found the Gingerbread Easter Egg?
Just go to the ‘About Phone’ menu under Settings, and tap multiple times on the Android version field and you should get the ‘Zombie Art’ featured in the thumbnail.
If you found this yourself with no help, well done and if you find anymore, make sure to post where you found it in the comments below!

Watch Android Take Over the World

The official Android Developers channel on YouTube has posted a beautiful vizualization of Android activations around the world starting in October, 2008, and progressing through January 2011. Quite impressive to watch -- especially the huge jump in activity when the Droid launched.
The video has no sound, so don't bother checking to see if you have mute on like I did. I'd recommend cuing up some dramatic musicbefore you hit play to enhance the experience.
Today finds us learning of another video which puts the more than 350,000 current daily activations into perspective.  Check out the video below for a clever infographic-like take on how Android is quickly becoming the preferred mobile OS around the world.  

суббота, 1 января 2011 г.

Новый 2011 год и магические свойства числа 2011...

Немного суеверные, но тем не менее весьма занимательные свойства числ 2011:
  1. 2011 - простое число
  2. 2011 - это сумма 11 последовательных простых чисел: 
    2011 = 157 +163 +167 +173 +179 +181 +191 +193 +197 +199 +211
  3. 2011 умноженное на симметричное 1102 есть число-палиндром:
    2011 х 1102 = 2216122
  4. 2011 умноженное на 2 и минус 1 также является простым числом:
    2011 х 2 - 1 = 
    4021
  5. Сумма цифр образует идеальный квадрат, аналогично сумма цифр квадрата 2011 также образует идеальный квадрат :
    2 + 0 + 1 + 1 = 4 = 2 
    ²
    2011 
    ² = 4044121 ==> 4 + 0 + 4 + 4 + 1 + 2 + 1 = 16 = 4 ²
  6. Ещё одно интересное свойство:
    13/05/2011  - пятница, 13-ое. Но это не самое исключительное.
    Интересным есть то, что сумма цифр 13052011 также есть 13 - это уже "двойная пятница 13"