Home

Wednesday, April 28, 2010

Bar Code generation in Android

 

I had an assignment in which I must how the sensor values as a bar code. For that I searched internet for the libraries. I found one here.

In the world of android who would pay to get such a library. If they are able to do it, even I can do it. Thanks to Google and XZing team. So, I finally found a way in the xzing site.

I downloaded the source code and created a jar file with the exact classes needed. The file can be download from here.

 

The code which I used to generate the bar code is here.

 

private void    generateBarCode()
    {
        img                 =   (ImageView)findViewById(R.id.img);
        Code128Writer c9     =   new Code128Writer();
        mBitmap          =   Bitmap.createBitmap(450, 150, Config.ARGB_8888);
        try {
            BitMatrix   bm  =   c9.encode( swapped? "tel:12345345": "tel:13453432", BarcodeFormat.CODE_128, 450, 150);
            mBitmap          =   Bitmap.createBitmap(450, 150, Config.ARGB_8888);
           for(int i=0;i<450;i++)
           {
               for(int j=0;j<150;j++)
               {
                   mBitmap.setPixel(i, j, bm.get(i, j)? Color.BLACK:Color.WHITE);
               }
           }
        } catch (WriterException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if(mBitmap!=null)
        {
            img.setVisibility(View.VISIBLE);
            img.setImageBitmap(mBitmap);
            showBarCode.setVisibility(View.GONE);
        }
        else

    }

 

The above code sets the bar code image to the view.

 

Please comment here if you need more help.

Saturday, April 24, 2010

Android 2.1 for Motorola Milestone

I flashed the German release of Android 2.1 by Motorola and I can see some of the issues I found with Android 2.0.1 is no more there in 2.1. Specially the orientation issue. The orientation issue is pathetic which does not allow to attend the incoming calls.

The improvement I see in Android 2.1 for milestone are:

1. Better battery life

2. Orientation issue is fixed

3. Few good features which I do not use, because live wallpaper consumes more battery.

4. The media dock application. this has real good improvement with a ‘bigger’ home screen button. Handy!. 

and2.1carhome

Friday, April 23, 2010

Make Opera Default Browser

Yah...

This app I made it to set the Opera Mini as a default browser when ever I click a URL or what ever.

This is a very simple app sits in the phone memory uses just 12KB of space. :)

Lets try it and see..

Please give me your comments and feature requests here.

Friday, April 16, 2010

How to kill the Android application completely?

ActivityManager actmgr=(ActivityManager)Settings.this.getSystemService(Context.ACTIVITY_SERVICE);
actmgr.restartPackage("<absolute package here>");