Archive

Posts Tagged ‘device’

Get an on-hand device: Samsung Galasy SII

December 7, 2011 Leave a comment

After long time waiting, I’ve had my chance to take own of the one I desire, the Samsung Galaxy S II – I9100.

Just testing and using it for several days, it’s really working great beyond my imagination.

Certainly, there will be more tutorials and articles on my blog from now on.

Categories: Of Diary Tags: , , , , ,

Get Current IP Address of Device

November 1, 2011 Leave a comment

Here a quick snippet I wrote to get current IP of device.

public String getDeviceCurrentIPAddress() {
	static final String DOT = ".";
	WifiManager wifiManager = (WifiManager)getSystemService(WIFI_SERVICE);
	int IP = wifiManager.getConnectionInfo().getIpAddress();
	return (
		(( IP >> 24 ) && 0xFF ) + DOT +
		(( IP >> 16 ) && 0xFF ) + DOT +
		(( IP >>  8 ) && 0xFF ) + DOT +
		(  IP         && 0xFF )
	);
}

Cheers,

Pete Houston

Connect to a specific device in Monkey script

July 7, 2011 1 comment

There are cases when you run many emulators in order to test their functions like sending messages, calling to each others …

and in Monkey scripts you need to connect to specific one.

Look at documentation on MonkeyRunner, you’ll see how to connect to a specific device:

Sample: if I want to connect to a device: “emulator-5556”, my connection part of script would be like:

device = MonkeyRunner.waitForConnection(120, "emulator-5556")

That’s all for it, now you can handle the rest of automation test for device.

Cheers,
Pete Houston

Check if SIM card available on device


Interesting snippet:

        TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
        if (tm.getSimState() != TelephonyManager.SIM_STATE_ABSENT){
          // The phone has SIM card
        } else {
          // No SIM card on the phone
        }

Refer to TelephonyManager class for more information.

Cheers,
Pete Houston

Categories: Tricks & Tips Tags: , , , , ,

Get files from emulator/device

June 25, 2011 6 comments

Sometimes, you might want to get files from devices for inspection, well, something like your SQLite databases, or file output…

This is how you do it:

adb pull [remote_device_path] [local_path]

Ok, a sample when I want to get my database from device to local:

adb pull /data/data/pete.android.study/databases/images.db C:\Downloads\images.db

Very effective and simple!
Hope you like it!

Cheers,
Pete Houston

Categories: Tricks & Tips Tags: , , , ,

Push files/directories into emulator/device

June 25, 2011 1 comment

In order to put files or directories into emulator/device, you need to issue command “push” from adb with following syntax:

adb push [local_path] [remote_device_path]

Here a sample if I want to put a file named ‘data.txt‘ into my folder in device: ‘/data/data/pete.android.study‘, I issue this command

adb push C:\data.txt /data/data/pete.android.study

To check whether the file pushed into devices succeeded or not, I will try:

ls /data/data/pete.android.study

If file ‘data.txt‘ appears, then it was pushed inside successfully.

Hope you like it!

Cheers,
Pete Houston

Categories: Tricks & Tips Tags: , , , , ,

Query emulator/device instance


This is a simple command, not everyone knows:

adb devices

It will display lists of devices’ serial number and its state (Offline / Attached).

Hope you like it!

Cheers,
Pete Houston