Archive for the ‘moblie development’ category

Android layout inflation and ID’s issue.

November 28th, 2011

In my course of creating an android app i’ve encoutered several times the issue of needing to inflate an extra layout or layout into existing layouts that you set with ‘setContentiew()’.

The process is simple, Since i’m usually using LinearLayout as my main layout all i have to do is get the LainearLayout objet using findViewByID(), inflate my new layout and use myLinearLayout.addView(inflaterView);
This does the trick hoever once it comes down to get save and restore for my form’s statefull items(checkboxes\EditText etc…) it doesn’t work. to see why it fails to work, let’s take a look on android’s code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
protected void dispatchSaveInstanceState(SparseArray<parcelable> container) {
        if (mID != NO_ID && (mViewFlags & SAVE_DISABLED_MASK) == 0) {
            mPrivateFlags &= ~SAVE_STATE_CALLED;
            Parcelable state = onSaveInstanceState();
            if ((mPrivateFlags & SAVE_STATE_CALLED) == 0) {
                throw new IllegalStateException(
                        "Derived class did not call super.onSaveInstanceState()");
            }
            if (state != null) {
                // Log.i("View", "Freezing #" + Integer.toHexString(mID)
                // + ": " + state);
                container.put(mID, state);
            }
        }
    }

So it’s all pretty simple. If you have an ID then call the View’s onSaveInstanceState() that will create a Parcelable of it’s state and will saved in a SparceArray(integer to Object Mapping that should be more effecient than HashMap) connected to it’s ID. If you have no ID than your data will not be automatically saved.
» Read more: Android layout inflation and ID’s issue.

9-patches insight – things you wont read on android’s doc.

September 4th, 2011

So i had to you a 9-path, for couple of month now i let our designer do the 9-path thing. If any of you think he bothered reading the docs. you are dead wrong :-) , designer, what did you expect happy little guy with 0 tolerance for long writings…. i used the 9-pathces for button’s backgrounds and for dialogs background, but alas! in some cases i got very very strange results which i could not understand. I had to turn to the documentation to check what it says regarding 9-patches and what the lines on top, bottom right and left actually mean…
» Read more: 9-patches insight — things you wont read on android’s doc.

Brew yourself an applet… part#1

August 30th, 2010

After 1 year of developing 2.1.x and 3.1.x brew devices and after witnessing the upcomming BREW MP software from Qualcom i’ve decided to give my BREW frustration it’s moment of glory.

So of all of ya guys that are not familiar and were brought up to the android\iphone age BREW stands for Binary Runtime Environment for Wireless and it’s been around for years, it was created nd is still maintained by Qualcom inc.
and wither this is the right plaform for you or if it’s a good\bad platform i’ll leave for the reader to decide, for my part i’ll just tell my story ;-)

So i worked in the LBS industry (Location Based Services) i ported our shared code to f\different devices and for one year my main goals was to write features and port and work and breath and breed just BREW platform applications.
So what is the BREW SDK for me really ? well i consider it to be C\C++ java, the SDK is pretty vast and cotains many features, from HTTP connections, to location services and even USB access on the device (though i’m not sure from which SDK version) but all in all, you have no real access (like symbian and WM and native code android) to the OS, you apps are first compiled to a binay, linked with the brew libraries using regualr linker (for arm that is) and then it’s changed to .mod file. You then need to get a signature file for your device and application (it’s hard binded to your IMSI) and you are pretty much done. like J2ME jad files BREW got a .mif file which is usually compiled from some form of JSON\XML file that was invented by Qualcom, in the old versions it was pure xml, today in brew MP i don’t know how to call it… » Read more: Brew yourself an applet… part#1

When open is not open (hint: not when it’s ajar ;-) )

July 11th, 2010

If any of you know the old riddle, “when a door is not a door ?” -> when it’s ajar (a jar, ajar – wide open) knows the headline :-)
But what I’m to talk about is the final release of the 2.2 code, well I’m a bit late with the post it’s been published about 3 weeks ago i believe.
» Read more: When open is not open (hint: not when it’s ajar ;-) )

Have you ever got a code you had to fix ?

April 1st, 2010

Today, here in this post I’ll do just like my blog’s headline suggest, cry out!

It starts with the fact that i got up today with stretched neck, add some knee pain i have for the last year or so that got worst an my  right hand’s middle finger (nop ,not a joke) have an inflammation and is swollen, so i had to walk around the office like the hunchback from Ramat Gan…

Add to this that we recently added up a new nice feature to our navigation app, the ability to navigate to a contact’s address that is in the android’s address book, and it would have stayed nice if not for and Romanian developer who developed it for us and the level of code that i got :-( . I had to fix it, and understand what is all the code that was written there…

» Read more: Have you ever got a code you had to fix ?

wrting a GUI for android with TextEdit bind.

March 13th, 2010

In the work i do i came across a strange bug we discovered only when dealing with LTR languages.

The problem was in the TextEdit object in the android platform.

The problem Was that when you change from landscape to portrait the textEdit gets the previous screen’s state size, that is in landscape it is the width of a portrait and in portrait the width of the landscape.

It’s important to emphasize that this is NOT an android bug but porting bug. The place i work in has it’s own GUI that to work all it needs is Graphics object that implements certain interface (with basic warding capabilities)  and transfer the touch events to the Framework that was created in house for handling.

» Read more: wrting a GUI for android with TextEdit bind.

The problem with in-house frameworks porting.

February 8th, 2010

I work i a company which basically likes to have it’s own GUI and tools framwork to work with for both java and c++ codes.

They first create the basic code, set up interfaces to work with “shared code” and then “platform code” is created to support different platforms (windows\linux\symbian etc…)

The real advantage used to be that:

1. we had some great (well relatively ;-) ) GUI when you compare it to the native GUI (on WM 6.5, old symbian devices and J2ME deices)

2. our applications looked the same on all platforms, major plus if you are used to our application and change your phone to a new platform.

3. most ports are easy enough.

It all looks pretty pinky on the horizon, only times have changed.

To be honest i think that even J2ME have prettier GUI these days and if not you can still use LWUIT which is open source.

» Read more: The problem with in-house frameworks porting.

properties properties: communication with the OS in J2ME

January 9th, 2010

Java Properties objects, ingenious invention! i always thought so!

You got key value pairs, think about it, almost everything you do gets down to that…

You need a bit more to serialize and de-serialize (type…) but in general you can use it for almost anything.

So why am i bullshitting so much about properties when it’s well known and exists for long in the community ? well in J2ME it’s not just  a nice object that can help you encapsulate stuff, the system properties are essential part of J2ME tat helps you get information on the device you are running on to do run time manipulation, if you want a single build that is….

» Read more: properties properties: communication with the OS in J2ME

Browsing Android source code in eclipse.

November 9th, 2009

A lot was said on this subject so i wont extend too much but i’ll do several things.

First of all i will point out the the article that helped me do it:

http://stuffthathappens.com/blog/2008/11/01/browsing-android-source-in-eclipse/ i think the article is clear and gives you a hint where and what to look for in the source code in it’s next generations.

Next i will point out that even though i did everything it said i had some problem with .pst based projects that were checkout out from the CVS. for some reason i could not see the source code.

Only after I’ve created a new project and tried to browse it did i succeeded, so take it into account.

Next i’m gonna tell you how basically you can get the source code:

  1. take this file in python, i must say i can’t remember where i got it from, but the guy who wrote it did a great job :-) it wasn’t me, just to make it clear…
  2. you have to get a linux machine (you might succeed with cygwin…)
  3. get the source code from git, follow the instructions here: http://source.android.com/
  4. you will likely get some network error , i did not succeed to get the source in a single attempt, and after that when i think, i mostly succeed but not always, just keep on running ./repo sync or ./repo init -u… until it’s done, i think the first times it took me like 2 days to get it all done.
  5. use the python script to get pack the source code into java packages.
  6. now you can open the source code in the right platform directory under ‘sources’ directory.
  7. you can use ./repo init -b cupcake or ./repo init -b android-sdk-1.5_r3 to get the right tag of the SDK sources before you pack it.
  8. if you are lazy check the links below I’ve made some ready made sources for 1.5, 1.6 and head (2.0) versions.

here are the links:
aaaaaaaa

  1. 1.5_R3: http://rapidshare.com/files/304445926/sources_1.5_r3.zip
  2. 1.6_R2: source code 1.6_r2
  3. 2.0 (Master branch): http://rapidshare.com/files/304452966/sources-master.zip
  4. 2.1_r2: 2.1_r2 sources
  5. 2.2: 2.2 sources

Enjoy :-)

managing files on J2ME devices

September 12th, 2009

You have an application , you  need to make your data persistent, i bet you know how, I’m not the first post regarding this issue, however i would like to show here the practical difference between using the file system (JSR75) and using the RMS on SonyEricsson, Samsung and LG devices.

» Read more: managing files on J2ME devices

Theme Tweaker by Unreal