Android SDK Linux quick setup

June 30th, 2011

Android SDK setup for Linux is a bit different than in Windows. I wrote quick instructions to setup Android development environment in Linux:

1. Setup Java dev environment:

First you need to install JDK and Eclipse

sudo apt-get install sun-java6-jdk eclipse

2. Install Android SDK starter package

sudo wget http://dl.google.com/android/android-sdk_r11-linux_x86.tgz

sudo tar -zxf android-sdk_r11-linux_x86.tgz

(Or download and extract manually from http://developer.android.com/sdk/index.html)

3. Install & configure ADT plugin for Eclipse

  • Open Eclipse and select from menu Help -> Install New Software
  • Add software source by clicking Add and give some name to repository and the following address:  https://dl-ssl.google.com/android/eclipse/
  • Select all tools and click next, next and accept the agreement and click finish
  • Restart Eclipse
  • After restart select Window -> Preferences… from Eclipse’s menu
  • Select Android from the left pane and set the Android SDK location to correspond with the directory where you extracted the started package in step 2

4. Install Android platforms and other components

Now you can download and install different Android platforms and create virtual images with SDK and AVD manager straight from Eclipse. (…or with android tool which is located in the sdk directory)

  • In Eclipse select Window -> Android SDK and AVD manager
  • From the left pane select Available packages and download & install the packages you want (Select 3rd party add-ons and Google APIs if you want to use e.g. Google Maps)
  • Platform tools will be downloaded to you SDK directory

5. Create test project and virtual images

Virtual images can be created with the Android SDK and AVD manager. Create and start one.

Now create new Android project:

  • Select File -> New Project -> Project...
  • Select Android -> Android project
  • Type in Project name, Package name and check build target from the list of downloaded & installed platforms. Click Finish
  • Run the project with Ctrl+F11, select Run as Android Application
  • Select a virtual image in where you want to run the application (or create one if you haven’t already)

6. Running applications in hardware devices

In Linux you have to manually add USB support for different device manufacturers.

Create and edit following file
sudo nano /etc/udev/rules.d/51-android.rules

Insert following text to the file:
SUBSYSTEM=="usb", SYSFS{idVendor}=="XXXX", MODE="0666"
where XXXX is the device manufacturers vendor ID. IDs are presented in the table below

Company USB Vendor ID
Acer 0502
Dell 413c
Foxconn 0489
Garmin-Asus 091E
Google 18d1
HTC 0bb4
Huawei 12d1
Kyocera 0482
LG 1004
Motorola 22b8
Nvidia 0955
Pantech 10A9
Samsung 04e8
Sharp 04dd
Sony Ericsson 0fce
ZTE 19D2

Set the permissions for the file:
chmod a+r /etc/udev/rules.d/51-android.rules

Now attach the device with usb cable and it should be recognized in the Run dialog.

PS. make sure you have turned the USB debugging on in the device (e.g. Settings -> Applications -> Development enable USB debugging)

Share and Enjoy:
  • Facebook
  • del.icio.us
  • MySpace
  • RSS
  • LinkedIn
  • PDF
  • Print

WordPress blog contents to external page

April 18th, 2011

This blog’s content is created and running with WordPress, but other content in my web site is not. So I needed a way to export latest blog post titles from the WordPress’ MySql database to other (non-WordPress) pages.

Here’s a PHP snippet for that:

$connection = mysql_connect(“localhost”, “database_user”, “database_password”);
  1. mysql_select_db("database_table", $connection);
  2.  
  3. $query = "SELECT post_status, post_date, guid, post_title FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 0, 6";
  4.  
  5. $result = mysql_query($query, $connection) or die("Query error!");
  6.  
  7. echo "
  8.  
  9.  
  10. <h3>Blog updates:</h3>
  11.  
  12. ";
  13.  
  14. for ($i = 0; $i &lt; mysql_num_rows($result); $i++) {
  15.    $link = mysql_result($result, $i, "guid");
  16.    $title = mysql_result($result, $i, "post_title");
  17.  
  18.    echo "
  19.  
  20. <a href="$link">$title</a>
  21.  
  22. ";
  23. }
  24.  
  25. mysql_close($connection);

Just edit “database_user”, “database_password” and “database_table” to correspond with your WordPress settings and paste the code to a web page you want.

You can see this code working in a sidebar of the other pages on this site.

Share and Enjoy:
  • Facebook
  • del.icio.us
  • MySpace
  • RSS
  • LinkedIn
  • PDF
  • Print

QMdiArea tabs with close button

March 6th, 2010

If you want to build an application with multiple document interface and tabs, you don’t have the close buttons in the tabs by default. That’s why I’ve come up with a workaround to get those buttons in every tab. Here’s a code example:

  1. Q_FOREACH (QTabBar* tab, ui>mdiArea>findChildren())
  2. {
  3.    tab>setTabsClosable(true);
  4.    connect(tab, SIGNAL(tabCloseRequested(int)),
  5.                this, SLOT(closeTab(int)));
  6. }
  7.  
  8. void MainWindow::closeTab(int i)
  9. {
  10.    QMdiSubWindow *sub = ui>mdiArea>subWindowList()[i];
  11.    QWidget *win = sub>widget();
  12.    win>close();
  13.    ui>mdiArea>setActiveSubWindow(sub);
  14.    ui>mdiArea>closeActiveSubWindow();
  15. }
Share and Enjoy:
  • Facebook
  • del.icio.us
  • MySpace
  • RSS
  • LinkedIn
  • PDF
  • Print

Filtering relational tables in Qt Sql

February 19th, 2010

I have a database which I’m using in my program which has foreign keys with same column name as in the table which it’s related. So I tried to set a filter to the related tables using setFilter(“relationtable.fieldName = ‘value'”), but it’s not working. I found out that Qt makes aliases to the relation table. Qt’s reference manual says “The alias is is the relation’s table name and display column name joined by an underscore (e.g. tablename_columnname)”.

I tried that but I think there’s somekind of bug because the query still says it’s an unknown column. However, I looked through the Qt’s Sql source code and found a solution.

For the relation table name you should use name like relTblAl_2, where the number after the underscore is the foreign key column in the main table.

Example:

  1. relTableModel>setTable("MainTable");
  2. relTableModel>setRelation(2, QSqlRelation("RelationTable", "ID", "Name"));
  3. relTableModel>setFilter("relTblAl_2.Name = 'Example'");

In this example table named RelationTable is aliased as relTblAl_2. By using the alias you can filter the values in the relational table.

Share and Enjoy:
  • Facebook
  • del.icio.us
  • MySpace
  • RSS
  • LinkedIn
  • PDF
  • Print

SpeedTest – Qt game

February 6th, 2010

It’s just basic clicking game made in a couple of hours but it was  good way to find out how to do a cross-platform project with Qt.

It builds with no problems for Symbian and Windows platform and probably to others as well with some tweaks. Especially great was the Qt’s interface for symbian touch screen devices. Qt handles the touches as mouse clicks so it’s easy to do programs/games which uses the touch screen devices.

Only drawback for developing with Qt for Symbian is the lack of the smart installer atm(release date Q1/2010?). It means, that you have to include the Qt installer to the .sis file which increases the size of the program. In the future Qt is included to the mobile phones so we’ll just have to wait for that.

Project information:  SpeedTest

Share and Enjoy:
  • Facebook
  • del.icio.us
  • MySpace
  • RSS
  • LinkedIn
  • PDF
  • Print

Testing applications with different Nokia phones

February 3rd, 2010

Nokia offers a great service for developers where you can test and install your applications with different Nokia mobile phones. All you need is an account for Nokia forums and you’re free to test different models.

List of available phone models

It’s a great tool to help you develop and test applications and verify the app’s functions without concretely owning all possible mobile phones. You can also use some debugging options in the service, like trace a Symbian panic information and text files in a real-time. You can also record the session with built-in screen capture.

Interface

The service is called Remote Device Access and it works with Java Runtime and browsers supported are Firefox v2+, Internet Explorer v7+, Opera v9.6+ and Safari v3+. It works with Google Chrome too.

Link: Remote Device Access

Share and Enjoy:
  • Facebook
  • del.icio.us
  • MySpace
  • RSS
  • LinkedIn
  • PDF
  • Print

Locking screen orientation to landscape in Qt for Symbian

January 31st, 2010

In my current project I’m programming a game for Symbian which will run only in landscape mode. So somehow I needed to lock the application to use only the landscape mode as some mobiles change the orientation automatically. I found a code snippet for that from Nokia’s forum.

The cone.lib, eikcore.lib, and avkon.lib Symbian libraries must be added to your Qt project:

//example_application.pro
  1. symbian: {
  2.     LIBS += lcone leikcore lavkon
  3. }

You also need some extra header files added to your source file:

//example_application.cpp
  1. #ifdef Q_OS_SYMBIAN
  2. #include <eikenv.h>
  3. #include <eikappui.h>
  4. #include <aknenv.h>
  5. #include <aknappui.h>
  6. #endif

Create a window to your app and include the  following code before the window is shown. It will lock the orientation to landscape mode:

  1. CAknAppUi* appUi = dynamic_cast (CEikonEnv::Static()>AppUi());
  2. TRAPD(error,
  3. if (appUi) appUi>SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);
  4. );

Now the orientation is locked and it will not change manually by user or automatically.

Share and Enjoy:
  • Facebook
  • del.icio.us
  • MySpace
  • RSS
  • LinkedIn
  • PDF
  • Print

Converting Nokia 5800’s videos to WMM and Youtube

January 28th, 2010

Nokia’s mobile phones and Apple’s iPods  records videos with .mp4 video format which isn’t supported by Windows Movie maker which I use to edit and compile videos. Therefore videos  have to be converted to .avi or .wmv which are supported by WMM.

pazera mp4 to avi

Pazera mp4 to avi converter v1.3

Free and easy to use tool for the conversion is Pazera mp4 to avi converter. It supports many different output formats and has settings to change the bitrate and codec freely. I’ve messed around with different settings and found out that best option for importing to WMM is WMV v.2 codec. I’ve set the output bitrate to 3000  kbit/s which produces good quality videos.

After the conversion with Pazera converter I import the videos to WMM. Aspect ratio has to be set to 16:9 if the videos are recorded in widescreen format.

From WMM it’s easy to save the edited video with default recommended settings and the video is ready to be uploaded to Youtube.

I made a video of the process:

Share and Enjoy:
  • Facebook
  • del.icio.us
  • MySpace
  • RSS
  • LinkedIn
  • PDF
  • Print

Nokia Sports Tracker motivates to train

January 24th, 2010
Sports trakcer in mobile

Sports tracker in a mobile phone

Nokia Sports Tracker is a mobile application to Nokia mobile phones which have internal gps-unit. You can track different activies (likecycling,running, skiing etc…) with it and it gives you information such as speed, distance, and time (even hearth rate if you have necessary equipment).

online view

Online service

But the best part of it is that you can upload your workouts to Nokia’s online service where you can see the route you ran in a map, music you listened or the pictures you took along the way. The workouts can also be shared in social networks like Facebook  and you can invite friends to join the training.

It’s still in a beta stage but it has all the functionalities to make it a great motivator to go out and do some workouts. Nokia Sports Tracker also won the Best Mobile Internet Service award in GSMA Global Mobile Awards 2009!

Endomondo

Endomondo is similar service and I’ve tried it also, but it doesn’t give so much information in the mobile’s screen as Nokia’s app does. Endomondo only gives you information about the time and distance as you do the workout when Nokia gives you all kind of different graphs about your workout. You can also send pictures to Nokia’s service but Endomondo does not have that ability. Endomondo’s pro in the other hand is that it  is supported in wide variety of different mobile brands.

You can find my Sports Tracker profile here.

Share and Enjoy:
  • Facebook
  • del.icio.us
  • MySpace
  • RSS
  • LinkedIn
  • PDF
  • Print