Friday, November 6, 2009

KeyboardView problem

A few days ago I tried playing with KeyboardView to make my own virtual keyboard for a little application. I had a big surprise which cost me a couple of hours (around 4-5). I even posted an issue here. Nothing special happened and no one responded to my post. I took the matter into my own hands and tried again different ways. I managed to locate the bug: THE CONTEXT. You cannot create a KeyboardView using the application context. You HAVE to use the Activity context. The developers from Android SDK said "they HAD to make the application context, but it doesn't really do anything" !? Maybe they SHOULD have warned the developers about the RISKS of using it. And by the way, if you use the Activity context and manage the orientation change event you WILL experience the memory leaks and the application crash.
So kids, do not play with Context at home. And if you do choose carefully whether to have memory leaks or to create your own KeyboardView (or maybe better, your own Android SDK).

Sony Ericsson Xperia X10 skin

It seems that Xperia X3 from my previous post is actually called X10 and it's indeed a new Android phone. You can find all the details here. I don't know when we will be able to buy one but if you're an Android developer you can at least use Xperia X10 skin on your emulator. The skin supports Android SDK 2.0 and you can download it from by clicking here. If you don't like it, you can find out other skins here.

Monday, November 2, 2009

Sony Ericsson Xperia X3 surprise





So there are about 24 hours left until Sony Ericsson comes up with news on Xperia X3 (also known as Rachael). There are some leaked pictures and technical specifications on the web but we can't get excited until tomorrow. But if the rumors will be confirmed this is going to be a hell o' a phone:
- OS: Android
- Processor: 1GHz Qualcomm Snapdragon
- Camera: 8 mega-pixels
- HSDPA (10Mbps)
- HSUPA (2Mbps)
- Navigation: AGPS
- Audio connector: 3.5mm (which is pretty cool)

With a little bit of luck in the near future we will be able to run Windows XP on a mobile phone using a virtual machine. All we need is a little bit of RAM and processor which supports visualization. Until then we, the mobile enthusiasts, will run XP on PCs and notebooks like normal people.

Sunday, November 1, 2009

AnimationDrawable problem

You may encounter a big problem when playing with an AnimationDrawable object in Android: it won't start! Actually it will remain blocked on the first frame and it will confuse you why it didn't start moving. So you may lose this way a couple of hours just trying to find where is the problem. The code seems to be okay, you did something like this:

public class Present extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout l = (LinearLayout) findViewById(R.id.main);
AnimationDrawable d = (AnimationDrawable) getResources().getDrawable(R.drawable.myanimation);
d.setBackgroundDrawable(d);
d.start();
}
}

I saw a couple of people complaining on forums but no one answered to their problem.
Now the catch is that no UI object is created until the onCreate function call is terminated. I assume that android internal framework doesn't start rendering the UI after setContentView, but it waits for the onCreate to terminate then it starts showing all the graphic elements. So what you need to do is call "d.start()" after we get past onCreate. Though I'm not saying it's the best solution, here is a little workaround:

public class Present extends Activity{
class AnimationStarterThread extends Thread{
private AnimationDrawable myAnimation;
public AnimationStarterThread(AnimationDrawable ad)
{
myAnimation = ad;
}
public void run()
{
ad.wait();
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
ad.start();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout l = (LinearLayout) findViewById(R.id.main);
AnimationDrawable d = (AnimationDrawable) getResources().getDrawable(R.drawable.myanimation);
d.setBackgroundDrawable(d);
AnimationStarterThread ast = new AnimationStarterThread();
ast.start();

//do other initialisations

ad.notify();
}
}


It's very far from an elegant solution. If I'll find a way to hook the event of UI post-initialization(this is the way to do it) I'll post an update.

Friday, October 30, 2009

Android 2.0



Android 2.0 is out! New features are available for developers and of course for the users. First of all let's start with the users news:

- you can add multiple accounts on a device for email and contact sync
- you can search for all SMS and MMS messages
- you can set the device to auto delete the oldest messages when a defined limit is reached
- built in flash support, digital zoom, scene mode, white balance, color effect, macro focus for the camera
- the new virtual keyboard makes it easier to hit the correct characters and improves writing speed
- double tap zoom, bookmarks with web page thumbnails, support for HTML5, database API, geolocation API inside the browser
- Bluetooth 2.1 with Object Push Profile (OPP) and Phone Book Access Profile (PBAP)

For the developers we have:
- new emulator skins
- debug/release application signing
- Bluetooth on/off, device and service discovery, data exchange via RFCOMM
- account manager for user/pass storing
- new parameters for color effect, scene mode, flash mode, focus mode, white balance, rotation, and other settings and ZoomCallback interface for Camera
- new API for retrieving image and video thumbnails on demand
- new system themes in android.R.style
- new WallpaperManager API
- new Service API
- advanced features for MotionEvent and KeyEvent

I saved the best part for "le grande finale" : Android 2.0 has the long expected multi-touch feature which will support up to three fingers touch simultaneously.

You can find a diff report here. And for more information about the release try here.

Halloween King of Lines

King of Lines is available now in "Halloween edition" on Android market. We will continue to make this game even better on future releases. If you want to propose new features please do so.




King of Lines Halloween edition

Thursday, October 29, 2009

Little Halloween application

Today we released another small game called Halloween Pumpkin. Since the Halloween will be here in a few days, we help you bring you this holiday on your Android phone. Trick or treat?




Halloween Pumpkin

Friday, September 25, 2009

Fennec Alpha 3 for Windows Mobile



     Fennec Alpha 3 for Windows Mobile is out and ready for download. For those of you who don't know what Fennec is I will say only three words "Mozilla mobile browser". Yeah, it's true and it will be available for multiple platforms like it's bigger brother(Firefox). Among those platforms there is Windows Mobile, Maemo, Symbian.
     For those of you who tested the previous release I'll just cut to the news of this version:
  • Much improved panning/scrolling performance
  • Improved start-up time
  • Revised theme
  • Support for running in full screen
  • Numerous bug fixes
  • Improved painting performance
  • Improved UI polish
  • Support for touch sensitive directional pad on HTC devices
  • Improved kinetic panning with directional locking
  • Ability to scroll frames
  • Improved zooming support
  • Support for multiple screen sizes

     I know I'm a little late with the post but I know there's never too late. You can find here a link to the full article.
    With this said I'd like to thank again Brad Lassey, my mentor in GSoC 2009, for all the support on my project.
     Thumbs up for Mozilla!

King of Lines

     King of Lines is a game I worked on and now is ready to download on Android Market(and it's free). It's a simple logic game: you have to make rows of five or more balls of the same color in every direction.
     It has a little menu which lets you create a new game, save the game, load the game, and has even the undo option. Right now you can undo a maximum of three moves, but we may in further releases make a settings panel from which you can select how many moves should be memorized.
     Another feature this game has is the automatically save that is triggered every time the application is closed.
     In the menu you can also find highscore and network highscore options. The first is functional but the second is "in developing" state and will be available in further releases.
     In the next version there is a possibility to let you chose the table size and the line size.

We are open to suggestions!




= Inatech team, simplegames.mobi project =

King of Lines

Thursday, September 24, 2009

Orientation change trick

     Today I was in need of stopping my application from resetting after the orientation change. What happens when the orientation change?
     Well, first of all the orientation change is managed by the default activity handler. And the default handling for this event is to restart an activity.
     What you need to do to stop the activity to be default handled is:

        1. Go to the manifest XML file and in the activity tag add the following attribute:

        android:configChanges="orientation"

        Now if you'll run the application an rotate the screen you will get the "java.lang.OutOfMemoryError: bitmap size exceeds VM budget" exception because the system runs out of memory since it still creates a new activity but the previous is not destroyed. So the solution is not solved yet.
 
       2. For the custom orientation change handling to actually take place you need also to override onConfigurationChanged method.

       @Override
       public void onConfigurationChanged(Configuration newConfig) {
               super.onConfigurationChanged(newConfig);
       } 



     Right now the problem is solved and you can change the orientation as many times as you like without the activity to get restarted.
     If you still get the "java.lang.OutOfMemoryError: bitmap size exceeds VM budget" exception it means that you have a little memory leak. You can find some advices on how to solve memory leaks problems here.
     If you get to try this solution you may want to take a look on the documentation and find out which other  config changes  you may manage manually.

Saturday, September 12, 2009

ERROR Error parsing XML file: Unbound prefix

In my last days I've been playing around with Android SDK making a little game. Found out the SDK is very poor in documentation and even some examples have errors.
I ran into the "Unbound prefix" error while trying to make a frame by frame animation. The example showed something like this:

 <?xml version="1.0" encoding="UTF-8"?>
 <animation-list   android:id="selected"  android:oneshot="false">
     <item android:drawable="@drawable/ballmove" android:duration="150"/>
     <item android:drawable="@drawable/ballmove2" android:duration="150"/>    
     <item android:drawable="@drawable/ballmove3" android:duration="150"/> 
</animation-list>  

but if you tryed it yourself you surely found out it isn't working.

The way to solve this stupid error is to add
xmlns:android="http://schemas.android.com/apk/res/android"
as the first attribute for the animation-list tag.

Friday, July 10, 2009

Unresolved external NS_NewGenericModule2...resolved

Today I tryed to build my first XPCOM module using this link. It's a great tutorial and you can make a XPCOM component in no time, but when I tryed to build it in windows I got this error:

Error 1 error LNK2001: unresolved external symbol "unsigned int __cdecl NS_NewGenericModule2(struct nsModuleInfo const *,class nsIModule * *)" (?NS_NewGenericModule2@@YAIPBUnsModuleInfo@@PAPAVnsIModule@@@Z)

I've searched and found out that I wasn't the only one having this issue. Some suggested you have to change the Gecko SDK version, but the real solution to the problem is this.
To solve the problem and set the flag in MVS you should go to Project > Properties > Configuration properties > Linker > Command line and then just paste "-LIBPATH:C:\...\gecko-sdk\lib xpcomglue_s.lib xpcom.lib nspr4.lib" in the Additional options textbox and voila!
Hope this helps!

P.S. I did't came with a new solution to the problem, but made it clear how to add linker flags to your MVS project.