buttons

 

ADB Concepts : How to ‘Launch an App & Close an App’ by using ADB Command

Get a step-by-step walkthrough in the video below!

Inthis Article, we are going discuss about launch/Stopping an app from the command line using ADB (Android Debug Bridge).

Topic-1 : Launching an App:

Though it’s easiest to launch an app by simply selecting it from the Home Menu, but we can also launch an app over adb

Basic Syntax:

Here’s a breakdown of the command:

  • adb shell: Opens a shell on the connected Android device.
  • am start: Uses the Activity Manager (AM) to start an activity.
  • -S: Forces the app to stop before starting, essentially restarting the app (useful for testing fresh app launches).
  • <package-name>: The application’s package name (e.g., com.example.myapp).
  • <activity-name>: The full name of the activity to start. If it's the main activity, it’s often something like com.example.myapp.MainActivity.

Example:

Topic -2 : Stopping/Closing an App:

Though it’s easiest to close an app by simply hitting the [X] button on the Home Menu, but we can also close an app over adb:

Basic Syntax:

  • adb shell: Opens a shell on the connected Android device.
  • amActivity Manager — a tool within Android that handles activities (apps), services, etc.
  • force-stop: A subcommand to forcefully stop a running app. It stops the app’s process and services..
  • <package-name>: The application’s package name (e.g., com.example.myapp).

Example:

What Happens When You Run This:

  • Android’s ActivityManager tells the system to immediately stop the app.
  • The app’s process is killed.
  • The app will not run again until you or the system explicitly starts it.

GitHub Link:


No comments:

Post a Comment