Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Is it possible to start an actual Android application from the command line in Android? For example, say I'd simply like to start/bring to the front my calendar. Is there a way that I can do this like:

startapp com.google.calendar
share|improve this question

1 Answer 1

up vote 10 down vote accepted

Using adb, I believe it is possible:

am [start|instrument]
am start [-a <action>] [-d ] [-t <mime_type>]
[-c <category> [-c <category>] ...]
[-e <extra_key> <extra_value> [-e <extra_key> <extra_value> ...]
[-n <component>] [-D] [<uri>]
am instrument [-e <arg_name> <arg_value>] [-p <prof_file>]
[-w] <component>

for example we have android program with Manifest as under:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.app1.android.xtract">
  <application android:icon="@drawable/icon">
   <activity class=".Contact" android:label="@string/app_name">
    <intent-filter>
    <action android:value="android.intent.action.MAIN" />
    <category android:value="android.intent.category.LAUNCHER" />
   </intent-filter>
  </activity>
 </application>
.
.
</manifest>

To run the code issue command like this (in one line):

am start -a android.intent.action.MAIN -n com.app1.android.xtract/com.app1.android.xtract.Contact
share|improve this answer
    
Unfortunately, it doesn't work over SSH for me, but it does when running adb so I'll give you that :) –  Naftuli Tzvi Kay Jun 13 '11 at 17:49
    
@NaftuliTzviKay It won't run over SSH because you don't have privilege to run am while adb does. Either you do adb shell over SSH in TCP/IP mode, or you issue su (root) and then follow the command. It will work. // Though you must have figured it out long time ago. :) –  Firelord 12 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.