Search code examples
androidadb

How to pass intent data when starting app via adb


I am able to start an activity with adb as below

adb shell am start -a android.intent.action.MAIN -n com.package.name/com.package.name.ActivityName

How do I add intent data to this command so that I can retrieve it from the started activity?


Solution

  • Here is some sample commands :

    # specifying the action and data uri
    adb shell am start -a "android.intent.action.VIEW" -d "http://developer.android.com"
    
    # specifying the action, mime type and an extra string 
    adb shell am start -a "android.intent.action.SEND" --es "android.intent.extra.TEXT" "Hello World" -t "text/plain"
    
    # specifying an explicit component name 
    adb shell am start -n "com.example.application/.MainActivity"
    

    The application With intent allow to send intent.

    I found those informations there : http://www.xgouchet.fr/android/index.php?article42/launch-intents-using-adb