Tuesday, September 7, 2010

Starting Android applications from shell

Starting application from the shell can be helpful in many scenarios. On scenario is when you want to limit the resources that the application is going to use with ulimit.
1. Start the shell.

2. Start the ActivityManager(am) command-line tool with appropriate parameters.
The syntax for the am command-line tool is the following.
ssue am command. am command syntax is as follow :
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>


3. Start the web browser with the following command.

am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity
to start your own application just type:
am start -a android.intent.action.MAIN -n "Your Package"/."Your Activity"
If you hare unsure of what your package and main activity are look in your manifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.TordSoft.HelloWorld">
  <application android:icon="@drawable/icon">
   <android:name=".HelloWorld" 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>

6 comments:

  1. When you run am (even without any argument, so it displays usage) and USB debugging is disabled the usage is displayed but the command never returns, it hangs.
    Any comment?

    ReplyDelete
  2. such a wonderful post.I like your blog ambition.I came to know some useful application about smart phone platform.

    ReplyDelete
  3. Interesting post. I learn something more challenging on different blogs everyday. It will always be stimulating to read content from other writers and practice a little something from their store.

    ReplyDelete
  4. Great informative post . You have included a lot of information that i was needed. now i can optimize my tablet myself . Thanks to sharing this post.
    Application Release Management

    ReplyDelete
  5. secret android commands : http://www.app-mug.com/2017/01/important-android-commands.html

    ReplyDelete