Android Tutorial

8.26.2011

Get version code and version name in android

      main:
         PackageInfo manager = ggetPackageManager().getPackageInfo(getPackageName(), 0);
        Log.d(TAG, "Version Code = " + getVersionCode(manager));
        Log.d(TAG, "Version Name = " + getVersionName(manager));


      /*
* get Version code
*
*  @para PackageInfo manager = ggetPackageManager().getPackageInfo(getPackageName(), 0);
*/
public static int getVersionCode(PackageInfo manager){
int verCode= 0;
verCode = manager.versionCode;  
   return verCode;
}

/*
* get Version name
*
*  @para PackageInfo manager = ggetPackageManager().getPackageInfo(getPackageName(), 0);
*/
public static String getVersionName(PackageInfo manager){
String verName = "";
verName = manager.versionName;  
   return verName;
}

8.25.2011

resizeImage trong Android.


 public static Drawable resizeImage(Context ctx, int resId, int w, int h) {

     // load the origial Bitmap
     Bitmap BitmapOrg = BitmapFactory.decodeResource(ctx.getResources(),
                                                     resId);

     int width = BitmapOrg.getWidth();
     int height = BitmapOrg.getHeight();
     int newWidth = w;
     int newHeight = h;

     // calculate the scale
     float scaleWidth = ((float) newWidth) / width;
     float scaleHeight = ((float) newHeight) / height;

     // create a matrix for the manipulation
     Matrix matrix = new Matrix();
     // resize the Bitmap
     matrix.postScale(scaleWidth, scaleHeight);
     // if you want to rotate the Bitmap
     // matrix.postRotate(45);

     // recreate the new Bitmap
     Bitmap resizedBitmap = Bitmap.createBitmap(BitmapOrg, 0, 0,
                                                width, height, matrix, true);

     // make a Drawable from Bitmap to allow to set the Bitmap
     // to the ImageView, ImageButton or what ever
     return new BitmapDrawable(resizedBitmap);

    }

7.24.2011

Developing Native Android Apps with Titanium

In today’s Titanium Week webinar, we took a look at features new and old for developing native Android applications using Titanium. Hacker Extraordinaire Marshall Culpepper surveys major Android native application concepts, like Activities, Intents, and Services, and shows how to apply these concepts in your Titanium application to create a deeply integrated native application experience on Android. Other cross-platform development techniques and code structure options are explored, and we tease our next great super demo app, Tweetanium!
Please find both the slides and recorded webinar below. In addition to Tweetanium, Marshall’s example project (used in this presentation) will be posted to GitHub early next week:

Android C native development – take full control!

EDIT Nov-2010 There is an easier way to compile native C code, see this article.
A recent project I've been working on required Bluetooth programming on the Android.
Having a quick look over the latest 1.5 Android SDK, I could see that bluetooth support was missing. Later research pointed out that Google expressively excluded Bluetooth APIs blaming lack of time.
On the other hand, I'm not a big Java fan, to say the least. I find Java unfriendly, and I don't like the look and feel of Java apps. Sorry, I prefer C/C++ since it provides better control and flexibility. So it's time to start doing C/C++ native applications for the Google Android.
How run a C program on Google Android?
First thing I'll show here, is to compile a simple C program for the Android.


#include <stdio.h>
int main()
{
printf("Hello Google Android world!\nwww.pocketmagic.net\n");
return 1;
}

7.13.2011

Top 5 Linux Video Editor Software

I'm looking for a free video editor similar to - Adobe Premiere Pro, Apple iMovie, Final Cut Pro or Microsoft Movie Maker under Linux Desktop operating system. My tasks are pretty simple such as cutting, filtering, and encoding tasks etc. Can you provide me a list of FOSS software which can be used for video capture and video editing purposes under Fedora or Ubuntu Linux desktop systems?

A non-linear editing system (NLE) is a video editing (NLVE) or audio editing (NLAE) system which can provide editing method for video clips or frams. You will be able to access any frame in a video clip. Non-linear editing is done for film and television post-production. However, the cost of editing system gone down and non-linear editing tools (including software) are now within the reach of most home users.
MS-Windows PC included Windows Movie Maker and Apple computer comes with iMovie. Most Linux based editing software can now be downloaded free of charge from the Internet. You also need a video capture card and a FireWire connection to capture digital video from a DV camera.

Avidemux

Converting Views to Bitmap Images in Android

When working with applications, developers can sometimes run in to a situation where they would like to create a view and then convert it to a Bitmap to work with it as an image. Learn how in this easy to follow guide.

In some applications, we would like to create a View with texts, images, and more view-elements and convert it to a Bitmap. Why? Well, you don't know until you need it, but imagine that you are working with OpenGL, you want to add textures to a OpenGL object, and you want these textures view-like. This is just an example, but I'm positive that more functionality will come to your mind while you are developing in Android.

Short introduction to Bitmap and Canvas