December 25, 2010

[SOLVED] Android: no adb on Suse linux or "???????????? no permissions"

You cant develop on your linux pc because you are getting something like this.
$ adb devices
List of devices attached
???????????? no permissions

temporary solution - to restart adb server as root
$ su
$ adb kill-server
$ adb start-server
$ adb devices

add your device to devices list.
1) check your vendor ID
$ lsusb
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 044: ID 18d1:2d66 <- this is my mobile
Bus 002 Device 004: ID 0451:2046 Texas Instruments, Inc. TUSB2046 Hub
Bus 002 Device 003: ID 10d5:0001 Uni Class Technology Co., Ltd

In my case , for Nexus One, it is 18d1

2) now add lines in to "/etc/udev/rules.d/51-android.rules"
$ su
$ vim /etc/udev/rules.d/51-android.rules

now paste these lines with your values
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"

save your file.

now it should work...


December 14, 2010

[SOLVED] Unix: search files between TIME1 and TIME2 with string 123456 in it


TIME1 = 2010-11-02 00:00
TIME2 = 2010-11-24 00:00
File pattern "PATTERN1231313123.txt"

create files with right timestamps
 touch -t 11020000 /tmp/stamp_2010-11-02_0000
touch -t 11240000 /tmp/stamp_2010-11-24_0000

check your list of files if it is right
find . -regextype posix-awk  -regex '^\./PREFIX[0-9]*.txt' -newer /tmp/stamp_2010-11-02_0000 -and -not -newer /tmp/stamp_2010-11-24_0000 -ls

export your list
 find . -regextype posix-awk  -regex '^\./PREFIX[0-9]*.txt' -newer /tmp/stamp_2010-11-02_0000 -and -not -newer /tmp/stamp_2010-11-24_0000 -exec grep --color "123456" {} \; > /tmp/mydata_123456.csv


December 13, 2010

[SOLVED] Android: Multiple substitutions specified in non-positional format

Getting an error after updating to SDK 0.8
Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? strings.xml

It happens in string files on strings with %
	"%s/%s (Linux; Android)"

You should change it to
	"%1$s/%2$s (Linux; Android)"


December 9, 2010

[SOLVED] PHP: Why 2 !=2 aka "never compare floating point numbers for equality"

“never compare floating point numbers for equality”.

The reason (19.6*100) !== (double)1960, is because inside a computer they are not equal.

Try this:


printf("%.15f", (19.6*100));


Outputs: 1960.000000000000227 (not 1960 as somewhat expected)

If comparison is required a few options come to mind (other than BCMath):

1) Round numbers before comparison:


$sig_figs = 5;
echo (round((19.6*100), $sig_figs) !== round((double)1960, $sig_figs)) ? 'not equal' : 'equal';


Outputs: equal


November 23, 2010

[SOLVED] helloWorldPlugin example from LiveView SDK 1.0 does't work

No example from LiveView™ SDK 1.0 work (helloWorldPlugin).

Getting something like (mPluginId=0):
D/LiveViewPlugin(15550): Plugin registered. mPluginId: 0 isSandbox? true
D/LiveViewPlugin(15550): Plugin installation notified.
D/LiveViewPlugin(15550): Registry success!

Just add in your manifest.xml
<uses-permission android:name="com.sonyericsson.extras.liveview.permission.LIVEVIEW_API"/>

Noow works everything perfect - you got your mPluginId and can play ;)
D/LiveViewPlugin(15843): Plugin installation notified.
D/LiveViewPlugin(15843): Registry success!D/LiveViewPlugin(15843): Plugin registered. mPluginId: 161427209 isSandbox? true
D/LiveViewKupriyanovPlugin(15481): startPluginD/LiveViewKupriyanovPlugin(15481): Enter HelloWorldService.startWork.


November 21, 2010

[SOLVED] How can i call Wi-Fi settings screen from my App

To start wifi settings dialog:
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));

to start Settings Dialog
startActivity(new Intent(Settings.ACTION_SETTINGS));

to start any settings dialog read the reference



[SOLVED] How to create Alert Dialog?

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
       .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
       .setNegativeButton("No", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
AlertDialog alert = builder.create();;


[SOLVED] How to check internet access on Android?

You can use


and parse the DetailedState enum of the returned NetworkInfo object


and don't forget to allow it the Manifest

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />




November 20, 2010

[SOLVED] Android: When the soft keyboard pops up, the EditText is invisible

Just add android:windowSoftInputMode="adjustPan" for your activity in manifest file
<activity android:name="SampleActivity" android:label="@string/app_name" android:windowSoftInputMode="adjustPan" >



November 16, 2010

[SOLVED] Android - Arrange two buttons next to each other and to center them horizontally.

Arrange two buttons next to each other and to center them horizontally.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="horizontal"
    android:background="@android:drawable/bottom_bar" android:paddingLeft="4.0dip"
    android:paddingTop="5.0dip" android:paddingRight="4.0dip"
    android:paddingBottom="1.0dip" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@+id/TextView01">
    <Button android:id="@+id/allow" android:layout_width="0.0dip"
        android:layout_height="fill_parent" android:text="Allow"
        android:layout_weight="1.0" />
    <Button android:id="@+id/deny" android:layout_width="0.0dip"
        android:layout_height="fill_parent" android:text="Deny"
        android:layout_weight="1.0" />



November 14, 2010

GTUG Bootcamp 2010 in Munich

Here yo will get small overview of  "GTUG Bootcamp 2010 in Munich". You can also go directly to picasa gallery to comment pictures there ;)

Stuttgart GTUG [@StuGTUG] goes GTUG BootCamp in Munich #gtugbc

October 28, 2010

[SOLVED] Install LaTeX and beamer on openSUSE 11.2

zypper in texlive-latex

Add this repository and search for beamer

October 24, 2010

[SOLVED] How do I install a Perl Module?

A) Start CPAN Shell:
# perl -MCPAN -e shell

B) Install a perl module:
At cpan> shell prompt install module using install module::Name command. For example install module called MIME::Lite:
# cpan> install MIME::Lite
Alternatively, try out the following command:
# cpan -i MIME::Lite

Source: How do I install a Perl Module?.

October 12, 2010

GAE: To python, or not to python

"To python, or not to python: that is the question: Whether 'tis nobler in the mind to suffer The strings and arrays of outrageous fortune, Or to take java against a sea of troubles, And by opposing end them?" #GAE

September 12, 2010

[SOLVED] Use github repository under windows with tortoisegit

Generate public and private ssh keys:

Just open "putty key generator" and generate (1) your key by moving your mouse on the surface.
Than wite some comment(2) and secure it with random passphrase (3).
Than save public and private key part on your file system.

Copy ssh-rsa key from "Public key for parsing into OpenSSH authorised_keys file:"- text field (you will need it for the next step)

Adding the key to your GitHub account:

Use this  tutorial

Use Pageant for auto authorisation:

If you dont want to put every time your ssh key password use Pageant. Just start it and add your private key

Get GitHub repository url:

Goto to desired project and copy git url from it:
For example: on it will be ""

Clone aka "Check Out" the repository:

Now create a folder on your PC and hit right mouse button on it - choose "Git Clone..."

In next dialog put the URL of git repository and choose path to your private github key you generated before.

Now push "OK" and enjoy the ride

Voilà ;)

August 26, 2010

install app to sd card in 2.2 (froyo)

-Go here
and get the SDK for your OS
-Once you download it, unzip it to its own folder, I put it off C:\
-Run the SDK Setup.exe
-Click available Packages, on left, I didn't know what was needed so I installed -EVERYTHING. Although I do suspect that we only need the USB driver, which is at the very bottom.
It will take forever to install.
After it's done installing, I Clicked on Installed Packages, and updated all.

Not done yet.
check that the phone is set up to allow debugging via USB (Settings⇒Applications⇒Development⇒USB debugging)
Plug in your phone
Windows will fail to install the driver.
Go in device manager and and update the newly Yellowed entry, the driver is in:
The driver should install

Start console: "Start"->"Run"->cmd->ENTER

> adb devices
if you see a serial number starting with an "H" that means you got things working, now do the following:
adb shell pm setInstallLocation 2

This command will push ALL apps to your sd card, to revert back to saving apps to internal memory enter in:

adb shell pm setInstallLocation 0

Source: install app to sd card in 2.2 (froyo)

July 27, 2010

[SOLVED] PHP: How upload file using cURL?

$request_url = ‘’;
$post_params['name'] = urlencode(’Test User’);
$post_params['file'] =@.'demo/testfile.txt’;
submit'] = urlencode(’submit’);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);

Source: How upload file using cURL?.

July 18, 2010

[SOLVED]Market Slowness and Accessibility on cyanogenmod's CM6 RC1

After upgrading to the latest Cyanogen I notices, that the Android Market is quiet slow and does not show my downloaded apps in the download section. 2 Fixes to repair this:

1) Take the following source and save in file named vending_preferences.xml

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<boolean name="local_db_sync_required" value="false" />
<int name="SERVER_VERSION" value="1000" />
<string name="vending_tos_version">1.0.0</string>
<long name="MARKET_LAST_HEARTBEAT_TIMESTAMP" value="1271657433127" />
<long name="last_sync_time" value="1271659724720" />
<long name="last_tickle_id" value="1271657514775" />
<int name="reconciled_version" value="1710" />
<boolean name="metadata_paid_apps_enabled" value="true" />
<string name="vending_backup_state">vending</string>
<string name="vending_tos_version">1.0.0</string>

Now push to /data/data/ :

adb push vending_preferences.xml /data/data/

Next you do in a terminal window (device or via adb shell):

cd /data/data/
rm *

Source: MattiDroid - Mobile Blog: N1/G1: Market Slowness and Accessibility.

July 17, 2010

[SOLVED]How customize/extend/ Spinner

You will need to take control over what goes into the ListView and
Spinner. I have not experimented with these techniques on Spinner, but
on ListView, you will need to override getView() (on ArrayAdapter) or
newView() and bindView() (on CursorAdapter).
Here is a free excerpt from one of my books that demonstrates the technique:

In your case, you would use your Typeface object to update the font used
by the TextView widgets in your rows.

In principle, you could do this via a wrapping adapter -- this would be
more reusable but a bit slower. I have an AdapterWrapper base class here:

and some projects that use it here:

You also need to override getDropDownView().

Source: How to change the Typeface of ListView and Spinner - Android Beginners Google Groups.

July 7, 2010

[SOLVED] Edit SQLite database of your app from your PC

Very nice solution to browse and edit the SQLite database file of your app directly from your PC.

  1. Download

  2. Set right path in settings.ini

  3. start it

java -jar AndroidDBEditor.jar

Or you can create small batch file AndroidDBEditor.bat
@echo off
rem set current path
set CURRENT_PATH=%~dp0

rem replace slashes

echo sqliteeditorpath=%CURRENT_PATH%sqlitebrowser.exe > settings.ini
rem start app
java -jar AndroidDBEditor.jar

Android DB Editor - its all about android.

July 1, 2010

[SOLVED] Set right permissions for svn repository

Additionally you should set umask 002 while working with a repository so that all new files will be writable by owner and group. This is made mandatory by creating a wrapper script for svn and svnserve:

mv /usr/bin/svn /usr/bin/svn.orig &&
mv /usr/bin/svnserve /usr/bin/svnserve.orig &&
cat >> /usr/bin/svn << "EOF"
umask 002
/usr/bin/svn.orig "$@"

cat >> /usr/bin/svnserve << "EOF"
umask 002
/usr/bin/svnserve.orig "$@"

chmod 0755 /usr/bin/svn{,serve}

Source: Running a Subversion Server.

[SOLVED] Fix default protocol (http...) association in WIndows

Setting default browser manually

You can manually set the default browser by selecting it as the the default program for individual file types and protocols, as follows:

  • Windows XP and earlier: Open the Control Panel from the Windows Start menu.

    • In Windows 2000 and earlier, or if Windows XP is using the Control Panel "Classic View": Click on "Folder Options -> File Types".

    • In Windows XP, if using the Control Panel "Category View": Click on "Performance and Maintenance". Then, click on "File Types" in the left column under the heading "See Also".

  • Windows 7 and Vista: Click the Start button, open "Default Programs" and then click "Associate a file type or protocol with a program". For detailed instructions, see the Microsoft article here for Vista or here for Windows 7. Note: On Windows Vista (or above), you may be unable to associate the HTTP HTTPS or FTP protocols with SeaMonkey because it does not appear as an available option. See this forum topic for additional information.

Assign the following protocols and file types to the browser you wish to set as default:

  • URL:HyperText Transfer Protocol (HTTP protocol)

  • URL:HyperText Transfer Protocol with Privacy (HTTPS protocol)

  • URL:File Transfer Protocol {FTP protocol)

  • HTML File

  • HTM File (optional)

In Windows XP and earlier, you can find the URL protocols listed above in File Types, under extension "N/A" or "(NONE)".

Source: Default browser - MozillaZine Knowledge Base.

June 10, 2010

[SOLVED] Convert signing certificate *.crt to *.spc

In order to convert the Certificate(mycert.crt) into a .spc file please run the following command:

openssl crl2pkcs7 -nocrl -certfile mycert.crt -outform DER -out newcertfile.spc

technoninja: thawte signing certificate howto mykey.pvk mycert.spc from .pfx file.

[SOLVED]How do I generate a certificate request with OpenSSL

openssl req \
-new -newkey rsa:1024 -nodes \
-keyout mykey.pem -out myreq.pem

If you’ve already got a key and would like to use it for generating the request, the syntax is a bit simpler.
openssl req -new -key mykey.pem -out myreq.pem

OpenSSL Command-Line HOWTO.

May 23, 2010

[SOLVED] Show web pages in Activity -Hello, WebView

WebView allows you to create your own web browser Activity. In this tutorial, we'll create a simple Activity that can view web pages.

Source: Hello, WebView | Android Developers.

May 20, 2010

[ANDROD] First screens of froyo. Android 2.2

Desktop screen



Music widget + overwiev of screens

Select "Input languages" for your multi-language virtual keyboard

for example german and russian

last started apps


our german keyboard


swipe on spacebar and we will get russian keyboard


May 9, 2010

[SOLVED] Android: Set Admob programmatically into test mode

(6) When integrating AdMob ads into your application it is recommended to use test mode. In test mode test, ads are always returned.

Test mode is enabled on a per-device basis. To enable test mode for a device, first request an ad, then look in LogCat for a line like the following:

  To get test ads on the emulator use AdManager.setTestDevices...

Once you have the device ID you can enable test mode by calling AdManager.setTestDevices:

  AdManager.setTestDevices( new String[] {                 
AdManager.TEST_EMULATOR, // Android emulator
"E83D20734F72FB3108F104ABC0FFC738", // My T-Mobile G1 Test Phone
} );

Source: Android - Admob For Developers.

May 6, 2010

[SOLVED] Android: hide/disable soft keyboard for activity

Just put stateAlwaysHidden attribute in your Manifest

 <activity name="EditContactActivity"

Source: The AndroidManifest.xml File </activity>

May 5, 2010

[SOLVED] Android: How to stress/test your app with random streams of user events

The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.

$ adb shell monkey -p -v 500

UI/Application Exerciser Monkey Android Developers.

May 2, 2010

[Solved] Android: Check if SD card is present

  1. public static boolean isSdPresent() {

  2. return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);

  3. }

Source: Android Snippets: Check if SD card is present.

[SOLVED] How-To HOW TO convert any video to your Nexus One

Source: How-To HOW TO convert any video to your Nexus One - Nexus One Forum - Google Phone Forum.

[SCREENCAST]How to do Unit Testing on Android with Eclipse

Source: How to do Unit Testing on Android with Eclipse -

[SOLVED] How to catch changes on "Key Press" from Soft Keyboard in EditText

editText.addTextChangedListener(new TextWatcher());  this interface
contains three methods,  which will be called accordingly when you
type using soft keyboard.

Source: Handling "Key Press" from Soft Keyboard in EditText - Android Developers | Google Groups.

[SOLVED] How to center window title

Just put in onCreate

TextView t=(TextView) findViewById(;

Alternative solution:

Source: Issue 4395 - android - android:gravity property ignored by TextAppearance.WindowTitle or WindowTitle - Project Hosting on Google Code.

May 1, 2010

[SOLVED] Error on creating custom dialog

> Use dialog = new Dialog(this);
> instead of
> dialog = new Dialog(getApplicationContext());

private void showAbout() {

protected Dialog onCreateDialog(int id) {
Dialog dialog = null;
switch (id) {
dialog = new Dialog(this);

dialog.setTitle("Custom Dialog");

TextView text = (TextView) dialog.findViewById(;
text.setText("Hello, this is a custom dialog!");
ImageView image = (ImageView) dialog.findViewById(;

// // do the work to define the game over Dialog
// break;
dialog = null;
return dialog;

Source: Custom Dialog - Android Developers | Google Groups.

[SOLVED]Android: How to Make an Activity Fullscreen

  1. public class FullScreen extends Activity {

  2. @Override

  3. public void onCreate(Bundle savedInstanceState) {

  4. super.onCreate(savedInstanceState);

  5. requestWindowFeature(Window.FEATURE_NO_TITLE);

  6. getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

  7. WindowManager.LayoutParams.FLAG_FULLSCREEN);

  8. setContentView(R.layout.main);

  9. }

  10. }

Source: Android Snippets: How to Make an Activity Fullscreen.

April 29, 2010

[SOLVED] Android: Convert dip to px.

It uses pixels, but I'm sure you're wondering how to use dips instead. The answer is inTypedValue.applyDimension()Here's an example of how to convert dips to px in code:

// Converts 14 dip into its equivalent px
Resources r = getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, r.getDisplayMetrics());

Source: Does setWidthint pixels use dip or px? - Stack Overflow.

[SOLVED] Android: Using Custom Fonts

Android comes with 3 fonts (Sans, Serif, Monospace) which can be accesed using android:typeface="FONT_NAME". But most of the times you would want to use your own fonts instead of the stock ones. Android provides an "assets" folder where you can put your TTF font files and access them from within the code.

There are two ways of doing this,

1. Assign the Typeface object to TextView,

2. Paint the Typeface on screen Canvas.

Method 1 - Assigning Typeface object to TextView

public void onCreate(Bundle savedInstanceState) 

TextView bauhs = null,chiller=null,broadw=null,joker=null ;
Button mag=null;

setFont(bauhs, "fonts/BAUHS93.TTF",;

setFont(broadw, "fonts/BROADW.TTF",;

setFont(chiller, "fonts/CHILLER.TTF",;

setFont(joker, "fonts/JOKERMAN.TTF",;

setFont(mag, "fonts/MAGNETOB.TTF",;


void setFont(TextView name, String path, int res)
Typeface font = Typeface.createFromAsset(this.getAssets(), path);



- "Typeface" is the class for handling fonts.

- The createFromAsset() method is used to specify the font path.

font object is assigned to the TextView name

Method 2 - Drawing the font on screen canvas

protected void onCreate(Bundle savedInstanceState)
setContentView(new FontView(this));

private static class FontView extends View
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Typeface mFace;

public FontView(Context context)

// mFace = Typeface.createFromAsset(getContext().getAssets(),"fonts/MAGNETOB.TTF");


protected void onDraw(Canvas canvas)

drawFont(canvas, "fonts/BAUHS93.TTF", 50, "Bauhaus 93");

drawFont(canvas, "fonts/BROADW.TTF", 150, "Broadway");

drawFont(canvas, "fonts/CHILLER.TTF", 250, "Chiller");

drawFont(canvas, "fonts/JOKERMAN.TTF", 350, "Jokerman");


void drawFont(Canvas canvas, String path, int y, String name)
mFace = Typeface.createFromAsset(getContext().getAssets(),path);

canvas.drawText(name, 30, y, mPaint);


- We need to extend the View class to access and override the onDraw() method.

- A Paint object is created which allows us to set the font size and color.

- The TypeFace object mFace is assigned to mPaint which is drawn on screen using the drawText().

drawText() takes 3 parameters, the text to be painted, its X-Y location and the Paint object.

Note: There is a difference between arial.ttf and ARIAL.TTF . If it ARIAL.TTF in your /assets folder and arial.ttf in your code, it will not work.

So if you have set the path correct but still wondering why the font is not being displayed, check this naming.

Source: Using Custom Fonts - ModMyGPhone Wiki.

[SOLVED] Creating and Using Databases in Android

Creating and Using Databases in Android.

April 17, 2010

[SOLVED] Copy MySQL database from one server to another remote server

Usually you run mysqldump to create database copy:
$ mysqldump -u user -p db-name > db-name.out

Copy db-name.out file using sftp/ssh to remote MySQL server:
$ scp db-name.out

Restore database at remote server (login over ssh):
$ mysql -u user -p db-name < db-name.out

How do I copy a MySQL database from one computer/server to another?

Short answer is you can copy database from one computer/server to another using ssh or mysql client.

You can run all the above 3 commands in one pass using mysqldump and mysql commands (insecure method, use only if you are using VPN or trust your network):
$ mysqldump db-name | mysql -h db-name

Use ssh if you don't have direct access to remote mysql server (secure method):
$ mysqldump db-name | ssh mysql db-name

You can just copy table called foo to remote database (and remote mysql server called bar using same syntax:
$ mysqldump db-name foo | ssh mysql bar

Source: Copy MySQL database from one server to another remote server.

[SOLVED] Move or migrate user accounts from old Linux server to a new Linux server

Commands to type on old Linux system

First create a tar ball of old uses (old Linux system). Create a directory:
# mkdir /root/move/
Setup UID filter limit:
# export UGIDLIMIT=500
Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts)
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig
Copy /etc/group file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig
Copy /etc/shadow file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig
Copy /etc/gshadow (rarely used):
# cp /etc/gshadow /root/move/gshadow.mig
Make a backup of /home and /var/spool/mail dirs:
# tar -zcvpf /root/move/home.tar.gz /home
# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail


  • Users that are added to the Linux system always start with UID and GID values of as specified by Linux distribution or set by admin. Limits according to different Linux distro:

    • RHEL/CentOS/Fedora Core : Default is 500 and upper limit is 65534 (/etc/libuser.conf).

    • Debian and Ubuntu Linux : Default is 1000 and upper limit is 29999 (/etc/adduser.conf).

  • You should never ever create any new system user accounts on the newly installed Cent OS Linux. So above awk command filter out UID according to Linux distro.

  • export UGIDLIMIT=500 - setup UID start limit for normal user account. Set this value as per your Linux distro.

  • awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig - You need to pass UGIDLIMIT variable to awk using -v option (it assigns value of shell variable UGIDLIMIT to awk program variable LIMIT). Option -F: sets the field separator to : . Finally awk read each line from /etc/passwd, filter out system accounts and generates new file /root/move/passwd.mig. Same logic is applies to rest of awk command.

  • tar -zcvpf /root/move/home.tar.gz /home - Make a backup of users /home dir

  • tar -zcvpf /root/move/mail.tar.gz /var/spool/mail - Make a backup of users mail dir

Use scp or usb pen or tape to copy /root/move to a new Linux system.
# scp -r /root/move/*

Commands to type on new Linux system

First, make a backup of current users and passwords:
# mkdir /root/newsusers.bak
# cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak

Now restore passwd and other files in /etc/
# cd /path/to/location
# cat passwd.mig >> /etc/passwd
# cat group.mig >> /etc/group
# cat shadow.mig >> /etc/shadow
# /bin/cp gshadow.mig /etc/gshadow

Please note that you must use >> (append) and not > (create) shell redirection.

Now copy and extract home.tar.gz to new server /home
# cd /
# tar -zxvf /path/to/location/home.tar.gz

Now copy and extract mail.tar.gz (Mails) to new server /var/spool/mail
# cd /
# tar -zxvf /path/to/location/mail.tar.gz

Now reboot system; when the Linux comes back, your user accounts will work as they did before on old system:
# reboot

Source:Move or migrate user accounts from old Linux server to a new Linux server.

[SOLVED] “Could not reliably determine the server’s fully qualified domain name, using ... for ServerName”


You might probably faced the same following error while you were restarting the Apache server on Ubuntu.

$ sudo /etc/init.d/apache2 restart
Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName

To fix that problem, you need to edit the httpd.conf file. Open the terminal and type,

$ sudo gedit /etc/apache2/httpd.conf

By default httpd.conf file will be blank. Now, simply add the following line to the file.

ServerName localhost

Save the file and exit from gEdit.

Finally restart the server.

$ sudo /etc/init.d/apache2 restart

Source: How to fix Apache – “Could not reliably determine the server’s fully qualified domain name, using for ServerName” Error on Ubuntu.

April 11, 2010

[SOLVED]How to determine screen size programmatically

public void onCreate(Bundle icicle) {
. . .
WindowManager w = getWindowManager();
Display d = w.getDefaultDisplay();
int width = d.getWidth();
int height = d.getHeight();

How to determine screen resolution programmatically - Android Developers Google Groups.

April 5, 2010

[SOLVED] Finding the name of installed applications

PackageManager pm = this.getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);

List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0);
for(ResolveInfo info: list)
Log.w("App browser", info.activityInfo.applicationInfo.loadLabel( pm ).toString());

Source: Finding the name of installed applications - Android Developers Google Groups.

April 4, 2010

Eclipse Tip: Toggle Block Selection Mode "Alt+Shift+A"

Just found the "Toggele Block Selection Mode" in my Eclipse 3.5.2 "Alt+Shift+A". Juuuhuuu!!!


[SOLVED] Intents, sending multily data aka ACTION_SEND_MULTIPLY

FileBrowser Send / Receive Intents

Blackmoon File Browser app has grown from a simple browser to a full fledged file manager and able to launch apps based on the given file name so that you don't have to launch the app and then open the file. Expanding on this idea, FileBrowser grew arms with which to pass off data to other apps in singles or multiples. FileBrowser then grew ears to listen for other apps that wish to use it's functionality to pick files or folders. Most of these Intents are discoverable, but any good dev knows that getting information directly from the source trumps whatever else is available. In this article, I will specify what Intents FileBrowser uses and how you can use them in your own app.

Launch App Intent

The simplest form of Intent used by FileBrowser is the launch intent. There are two methods being used. One specific to "Open File" and the other is used by "Open with...". Open File is used to launch the default activity for the given file's MIME type. Determining a file's MIME type is beyond the scope of this article.
In the example, you want to VIEW the file which has a MIME type of theMIMEtype.
String theMIMEType = getMIMEtype(aFile);
if (theMIMEType!=null) {
Intent theIntent = new Intent(Intent.ACTION_VIEW);
theIntent.setDataAndType(Uri.fromFile(aFile), theMIMEType);
try {
} catch (ActivityNotFoundException anfe) {
//show error

Since you declare what the MIME type is supposed to be, any file can try to be opened by any app... most likely it will not, but this allows for opening up an HTML file in a text editor rather than a web browser. If there is more than one app that is capable of handling the launch request for the given MIME type, Android will ask the user to pick one and give them the option of making that choice the default which would prevent Android from asking again in the future.

"Open with..." has a slightly different form of app launcher in that the startActivity() is called with a Chooser rather than merely relying on the default chosen for a particular MIME type. FileBrowser goes an extra step further and instead of merely using the MIME type of the given file, it uses the MIME category instead. A .jpg file with a MIME type of "image/jpeg" would have a MIME category of "image/*". This means that an image viewer that is able to open images, but not necessarily JPEG images will also be included in the list of apps that can receive this file. FileBrowser does this to allow more flexibility in how you can open a file since you sometimes want to use a slightly different app than the default one.
Intent theIntent = new Intent(Intent.ACTION_VIEW);
String theMIMEcategory = getMIMEcategory(aFile);
try {
} catch (Exception e) {
//show error

These two VIEW action Intents are the basic examples of how FileBrowser launches an app to open any given file. It launches them as separate apps so that it mimics what a person would actually do on their phone by launching the proper app and then loading that particular file to use with that app. Using FileBrowser merely changes the order of those steps so that you can see what file you wish to use first and then launch the proper app.

Listening for Intents

Listening for Intents is a two step process. The first step being to tell the AndroidManifest.xml which Intents to listen for and what Activity to launch in response to one. A single activity can have more than one Intent filter. FileBrowser's main activity has 3 intents associated with it. The first is the standard main app launcher. A second Intent filter deals specifically with the various pick Intents. The third Intent filter is a specialized pick filter - GET_CONTENT. Here is how FileBrowser defines the later two filters:
<action android:name="android.intent.action.PICK" />
<action android:name="org.openintents.action.PICK_FILE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:scheme="folder" />
<data android:scheme="directory" />
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="*/*" />

The first filter states to the Android system that it will accept any action that equals PICK or PICK_FILE. The OR is very important as this only applies to other actions listed in the same filter. We narrow down the PICK actions by specifying that in addtion to either PICK or PICK_FILE, the Intent must also have a data scheme of either "file" or "folder" or "directory". Any combination of Actions and Data Schemes that match that criteria will consider FileBrowser as a potential recipient for the Intent. The categories listed are DEFAULT, which every Intent filter should have, and BROWSABLE, meaning that your Activity is safe to use from a web browser.

The second filter is the GET_CONTENT filter, again listing the DEFAULT category all public filters should have as well as OPENABLE, meaning your activity is able to open the content the Intent is requesting. The data mimeType of "*/*" means that we are capable of opening and returning any MIME type desired. This filter was put into FileBrowser specifically to handle email attaching from the Gmail/Email apps. When Gmail asks Android for an app capable of attaching content to the email, FileBrowser will be listed as one of those apps that can pick a file to attach.

The second step in the process of responding to an Intent is to write the code necessary to send the data back to the requesting app. Since I have already covered how to write such code in an earlier article, I am just going to provide a link to it.

Sending a "Single Datum" Intent

Sending a single file is very similar to opening it. The difference is the Action to use and the Extras needed. The typical recipient for a Send request is email, but any number of apps can also receive such an Intent. I like to think of Send Intents as a kind of throw/catch arrangement as opposed to the View Intent which is more of a "point and look" arrangement.
String theMIMEType = getMIMEtype(aFile);
if (theMIMEType!=null) {
Intent theIntent = new Intent(Intent.ACTION_SEND);
theIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(aFile));
//next line specific to email attachments
theIntent.putExtra(Intent.EXTRA_SUBJECT, aFile.getName());
try {
startActivity(Intent.createChooser(theIntent, aChooserTitle));
} catch (Exception e) {
//show error

FileBrowser uses the Send Action, sets the MIME type for the file to be sent, but does not set the Data portion of the Intent. Instead, we add an Extra, specifically an EXTRA_STREAM, with the file Uri as it's value. The EXTRA_SUBJECT is not required, but is an optional feature specific to the email apps that use this Intent to attach files to an email.

Sending/Receiving a "Multiple Data" Intent

This particular feature of FileBrowser is not well defined elsewhere for Android apps. There is no real standard or example to follow and there isn't too many apps that can actually handle multiple files. Hopefully this article will allow more developers to understand and incorporate handling multiple data points (files in our case) into their apps.

Sending multiple files from FileBrowser first requires some mechanism to select mutiple files and organize them somehow. The implementation details of such are not important. Suffice to say, by the time we are ready to send multiple file Uris, we can get an ArrayList from our internal structure. The difficult part is not the packing of the list into the Intent, but actually analyzing each file Uri that is going into it so that the "overall" MIME type for the given list is set as the Intent type.

Sending Multiple

public static String getMIMEcategory(String aMIMEtype) {
if (aMIMEtype!=null) {
aMIMEtype = aMIMEtype.substring(0,aMIMEtype.lastIndexOf("/",aMIMEtype.length()-1))+"/*";
} else {
aMIMEtype = "*/*";
return aMIMEtype;

protected boolean packageMarkedFiles(Intent aIntent) {
ArrayList theUris = myFilesToSend.toUriList();
//iterate through the list and get overall mimeType
String theOverallMIMEtype = null;
String theMIMEtype = null;
String theOverallMIMEcategory = null;
String theMIMEcategory = null;
Iterator iu = theUris.iterator();
while (iu.hasNext()) {
String theFilename =;
theMIMEtype = getMIMEtype(theFilename);
if (theOverallMIMEtype!=null) {
if (!theOverallMIMEtype.equals(theMIMEtype)) {
theOverallMIMEcategory = getMIMEcategory(theOverallMIMEtype);
theMIMEcat = getMIMEcategory(theMIMEtype);
if (!theOverallMIMEcat.equals(theMIMEcat)) {
theOverallMIMEtype = "multipart/mixed";
break; //no need to keep looking at the various types
} else {
theOverallMIMEtype = theOverallMIMEcat+"/*";
} else {
//nothing to do
} else {
theOverallMIMEtype = theMIMEtype;
if (theUris!=null && theOverallMIMEtype!=null) {
return true;
} else {
return false;

protected boolean sendMarkedFiles() {
Intent theIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
if (packageMarkedFiles(theIntent,false)) {
startActivity(Intent.createChooser(theIntent, aChooserTitle));
return true;

As before, determining a file's MIME type is beyond the scope of this article. Once you run through your list of file Uris and determine what the overall MIME type for the list is going to be, filling the Intent is quite simple as it becomes one call to putParcelableArrayListExtra().

Receiving Multiple

Receiving an ACTION_SEND_MULTIPLE Intent is also fairly straightforward since you just call the opposite method to retrive the list of Uris.
Intent theIntent = getIntent();
if (theIntent!=null) {
String theAction = theIntent.getAction();
if (Intent.ACTION_SEND_MULTIPLE.equals(theAction)) {
theFileList = theIntent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);

Once you have your file Uri list, you can act upon it however you wish. Also, do not forget to put an Intent filter on your activity in the AndroidManifest.xml. The one FileBrowser uses to create playlists from multiple audio files is shown.
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="audio/*" />

I encourage other developers to incorporate listening for SEND_MULTIPLE requests into their apps that also listen for single requests. They do not add much more complexity to your app and if you are only listening for them, it is not hard at all to add it as a feature.

Source: FileBrowser Send / Receive Intents.

Another example yo can find on