Categoryxml

Quantity Strings (Plurals)

Did you know: you can easily translate quantity string with build-in Android tools!:)

Check it out http://developer.android.com/guide/topics/resources/string-resource.html#Plurals

//DL

Android tutorial slides

I would like to share some Android-related tutorial slides that we presented with Alexey in 2010 (http://habrahabr.ru/blogs/android/95250/) at St.Petersburg GTUG.

Some tips are still actual. So some of you could find it helpful;)

«Java and Android basics» (78 slides)

http://vk.amberfog.com/gtug/part1_Introduction2JavaAndroid_gtug.pdf

1.     Java and Android code style
2.     Java Collections
3.     Dalvik – Java Android VM
4.     Memory management in Java (GC + hard, soft, weak, phantom references)
5.     Java Exceptions handling
6.     Multithreading in Java
7.     Android Architecture
8.     Android entities: Activity, Service, Intent, BroadcastReceiver, ContentProvider
9.     Android Application, Context and Manifest
10.   Android System Services
11.   Android platform fragmentation and Java Reflection
12.   Saving state of application
13.   Android NDK
14.   Optimization for mobile: Design for better performance, responsiveness, seamlessness


«Android UI» (81 slides)

http://vk.amberfog.com/gtug/part2_WorkingWithAndroidUI_gtug.pdf

http://vk.amberfog.com/gtug/part2Examples.zip

1.     Activity lifecycle
2.     Activity, Layout, View, UI events, XML layouts
3.     XML layout’s types: FrameLayout, RelativeLayout, LinearLayout, TableLayout
4.     Layout tricks: merge, ViewStub, include
5.     Work with ListView and Adapters
6.     Menu & Dialogs
7.     UI thread! (and ANR)
8.     Developing custom UI-elements
9.     UI-development for difference screen resolutions and Android platform versions
10.   UI layout-tree analysis and optimization with special tools (hierarchyviewer, layoutopt)
11.   UI performance improvements
12.   UI guidelines
13.   Styles, Themes, Activity based dialogs
14.   Widgets, Live Folders, Live Wallpapers

«Android in Action» (69 slides).

http://vk.amberfog.com/gtug/part3_AndroidInAction_gtug.pdf

1.     Dealing with screen orientation change
2.     Possible causes of memory leaks: analysis and tools
3.     Data flow: Parcelable, Bundle, etc.
4.     android.app.Service
5.     Effective XML data parsing protocol
6.     Working with Databases
7.     Input Methods
8.     Search Providers
9.     Debugging hints & tools
10.   Battery life
11.   Usage statistics: Flurry
12.   Application signing and publishing

enjoy

//DL

Google Android secret_code for testing

Found today a post

  1. Go to phone app
  2. Dial *#*#4636#*#*
  3. See secret test menu:)

*#*#4636#*#*

I’ve looked deep into platform code. Here’s are the code from Phone.git

    static boolean handleSecretCode(Context context, String input) {
        // Secret codes are in the form *#*#<code>#*#*
        int len = input.length();
        if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
            Intent intent = new Intent(Intents.SECRET_CODE_ACTION,
                    Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
            context.sendBroadcast(intent);
            return true;
        }

        return false;
    }

So, let’s search for Intent filters:

Settings.git

        <receiver android:name="TestingSettingsBroadcastReceiver">
            <intent-filter>
                 <action android:name="android.provider.Telephony.SECRET_CODE" />
                 <data android:scheme="android_secret_code" android:host="4636" />
            </intent-filter>
       </receiver>

CalendarProvider.git (this one works only on >2.0)

        <receiver android:name="TestingSettingsBroadcastReceiver">
            <intent-filter>
                 <action android:name="android.provider.Telephony.SECRET_CODE" />
                 <data android:scheme="android_secret_code" android:host="225" />
            </intent-filter>
       </receiver>

VoiceDialer.git

      <!--  Voice Dialer Logging Enabled, *#*#VDL1#*#* -->
      <intent-filter>
        <action android:name="android.provider.Telephony.SECRET_CODE" />
        <data android:scheme="android_secret_code" android:host="8351" />
      </intent-filter>

      <!--  Voice Dialer Logging Disabled, *#*#VDL0#*#* -->
      <intent-filter>
        <action android:name="android.provider.Telephony.SECRET_CODE" />
        <data android:scheme="android_secret_code" android:host="8350" />
      </intent-filter>

You can add your own codes!:)

//DL

How weight in LinearLayout works

This post is just a quick review of LinearLayout weight attribute.
Here’re a few things:

  1. If you want to divide the space equally between Views with the same weight – set 0dp as Views’ width
  2. If you set View width to wrap_content – size of the Views will depend on weight and content inside each View

hope it will help you to better understand LinearLayout weight idea.

//DL

ldpi/hdpi layout folders and Android 1.5

There’s a problem if you develop platform-independent solution. If you have two folders like layout-land and layout-land-ldpi – Android 1.5 takes files from layout-land-ldpi folder. To avoid this just add v4 to the folder name like layout-land-ldpi-v4.

Please make sure that you have correct versions in you AndroidManifest.xml:

<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4" />

Android perfect UI: fighting with dithering

Everyone who tries to use gradients in the images on mobile device comes to the problem: how to make gradients look nicely? The answer is simple – dithering.

I will try to give some tips here about dithering images for Android devices. This is updated version of my previous post about dithering.

First of all you can make dithering in 2 ways:

  1. Dither images from the code or XML on the fly
  2. Pre-dither images in image editor software

Dither images from code

Let’s consider an example: you are trying to make a perfect button for your perfect UI.
You made a superb sketch in (let’s say photoshop) and want to transfer it to your G1 device. In the image editor software the button looks nice:

original button in photoshop

Then try to insert it to the Android Activity layout as ImageView with android:src.

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/b1" />

android - no dither

It looks… horrible isn’t it? Let’s try to apply dithering from XML.

Continue reading

“Loaded time zone names for” during XML parse

Do not use java.util.Date object in XML parse! Because if you once change locale in your phone settings – XML.parse() could take couple minutes.

You will see

I/Resources( 1088): Loaded time zone names for en_uk in 1764ms.

in your DDMS log as well as huge gc() work.

onLongClick custom selection

If you want to make custom Listview selection you may probably need custom longclick selection (to show long click in action). This may be done with transtion tag in android.
Continue reading

SOAP in Android

Like many other Android developers I came to the same problem – parsing SOAP in Android.
My short instruction how to do this…
Continue reading

Parsing XML: android.sax package

I’ve just discovered that Android has wrapper for SAX parser that simplifies your code and prevents common mistakes without sacrificing any performance.

import android.sax.*;

http://developer.android.com/reference/android/sax/package-summary.html

You can find very helpful usage example here: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=tests/AndroidTests/src/com/android/unit_tests/SafeSaxTest.java;h=d488a29bdf02ace92f6cbc6f8a42b5d7c42308db;hb=refs/heads/cupcake

happy parsing!

© 2019 Android Tales

Theme by Anders NorenUp ↑