It's been a long time since I found the Android application I'm developping ( a word game ) was not as responsive as I would like.
As I don't have any kind of Android phone, all of my testing happen in the emulator, and I'm not sure how well it fits the phone reality ( and actually, I'm aware that this does not mean anything, as there may be a lot of different phones out there... ).
But still, I expected the emulator to be in scope with reality, and to give me a good start to measure responsiveness ( and actually, I have no other choices ).
So the responsiveness of my application was below my expectations, and I had planned a optimization phase to fix it as much as I could.
And yesterday, I found myself manipulating my game, and finding it was responsive enough for me !
It took me a little time to understand what had changed, as I never tried to optimize it, and my last developments were GUI / cosmetic changes !
Actually, I had disconnected the debugger !
When my application is running with eclipse connected to it, it is way slower than it is without it !
Although it is a simple optimization, and quite reassuring for my game, it is the second time that having eclipse connected to the emulator gets in my way ( the first time being with the profiler : here ).
And that is more perturbing...
A blog from an Android developer.
Developing since the start of the platform, and constantly improving my applications, I share my experience developping with Google OS for smartphones.
Monday, February 2, 2009
Thursday, January 29, 2009
How to have a tiled background ( cont.)
Thanks to Romain Guy, I finally could add a repeating background in my Android application !
I'm still using in my layout definition the same way to define the background, with a androidbackground parameter, with the path to your repeating background ( actually that was the point : having a consistent way for background, let them be tiled or not )
xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/MainLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/backrepeat"
>
...
<LinearLayout
android:id="@+id/MainLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/backrepeat"
>
...
in my drawable directory, I have a back.png file ( the background I want to tile ), and I create this new backrepeat.xml file :
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/back"
android:tileMode="repeat" />
Some points :
* I think my first tries failed because I forgot the 'xmlns:android' parameter.
* I tried without the xml version line, and it still works, but I think I will let it be there... Just in case !
* The tilemode can be repeat, mirror, or clamp.
* Although in Java, I could set a different repeat mode for X and Y, I don't think it is possible in the Xml file. Not that I really care for the moment :)
That's all !
Thanks again Romain !
I know it is your job, as a Android engineer, to evangelise and help us, but several times you really helped me, you were quick to answer, with concise and most useful answers...
Saturday, January 24, 2009
How to have a tiled background
Today, I wanted to have a tiled background in my activity.
Until now, my android application only had a stretched image, so I though it was a good time for a change !
Having a background pattern that repeat itself seems like a very common idea, in particular on mobile development where you do not want to spend too much memory on a big image !
But actually it took much more time that I would have think to find this one !
I finally came up with this code :
public void onCreate(Bundle savedInstanceState)
Until now, my android application only had a stretched image, so I though it was a good time for a change !
Having a background pattern that repeat itself seems like a very common idea, in particular on mobile development where you do not want to spend too much memory on a big image !
But actually it took much more time that I would have think to find this one !
I finally came up with this code :
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main_menu);
View MainLayoutView = (View) findViewById(R.id.MainLayout);
BitmapDrawable MyTiledBG = new BitmapDrawable( BitmapFactory.decodeResource(getResources(), R.drawable.background) );
MyTiledBG.setTileModeXY( Shader.TileMode.REPEAT , Shader.TileMode.REPEAT );
MainLayoutView.setBackgroundDrawable( MyTiledBG );
<...>
}
(note that you can use also Shader.TileMode.MIRROR to have a different repeatition pattern )
This code works fine, but I would have prefered a XML way to do this.
I've seen the BitmapDrawable attribute defined in the SDK, but couldn't come with anything working...
Tuesday, January 20, 2009
Sliding drawer, again
The sliding drawer developped by pskink has gone quite a long way from where it came from, and is now a really nice and, I think, usable widget, much like the google home page one !

This kind of widget is fun to use, and fits really well for mobile applications, where there is an obvious lack of place. And, on google phone, users are used with this widget, as there is one on the home page !
Here are some screen of this widget in action :

Enjoy !
[Edit ] :
Ooooppss...
I forget to add the link to the source :
You can find it here !
[/Edit]
Friday, January 16, 2009
Sliding Drawer
Interested in the Home Page sliding drawer ?
pskink has created a new widget like the google one.
Nice job, and easy to use...
Here it is :
Enjoy !
Subscribe to:
Posts (Atom)