Showing posts with label adb. Show all posts
Showing posts with label adb. Show all posts

14 September, 2010

Journey of Android Development -- Installed on Phone

After 'cutting my teeth' with the emulator I embarked on installing my simple app on my phone.

A couple setup steps that are worth mentioning for my Samsung Galaxy.

First, you need to enable the USB debugging on the phone. This is done by enabling Settings->Applications->Development->USB debugging

By default, the usb connection is only accessible by the root user. You can leave it in this mode, but the consequence is that you'll have to start the adb server as root to attain the permissions to connect to the phone.

$ sudo adb kill-server
$ sudo adb start-server


After you've done this you'll be able to list and connect to the phone as a general user.

$ adb devices
List of devices attached
T9592dbc8xxx device


Now, you're able to connect to your phone in the same manner as the emulator.

Cheers.

12 September, 2010

Journey of Android Development -- Running Apps vi Adb Command Line

Ok, so you're developing the next killer app for Android. If you're anything like me, and pray you aren't, you may find you want to start your app from your development machine via the emulator.

I posted how you can install, reinstall, and uninstall your app in previous posts. This post builds on that.

Issuing an 'adb shell' command essentially executes a shell command on the emulator. If you issue a command you'll execute the command rather than enter an interactive shell.

The Activity/Intent Manager/Messenger tool allows you to start your activity through the adb command line.

The trick is to define the command arguments properly, which is done by pulling relevant information from your AndroidManifest.xml file. You need to specify the proper action and component in your command line, extracted from your Android Manifest.

Given the following AndroidManifest.xml file:

user@debian:~/Buttons$ cat -n AndroidManifest.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.example.buttons"
4 android:versionCode="1"
5 android:versionName="1.0">
6 <application android:label="@string/app_name">
7 <activity android:name=".Buttons"
8 android:label="@string/app_name">
9 <intent-filter>
10 <action android:name="android.intent.action.MAIN" />
11 <category android:name="android.intent.category.LAUNCHER" />
12 </intent-filter>
13 </activity>
14 </application>
15 </manifest>


The action is defined in line 10, the component defined as lines 3+7 respectively.

You can start the 'Buttons' activity by specifying the following command:

adb shell am start -a android.intent.action.MAIN -n com.example.buttons/com.example.buttons.Buttons