Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ADB4J: Android Debug Bridge for Java

ADB4J is a Java library that provides an easy-to-use interface for Android Debug Bridge (ADB) commands within Java applications. With ADB4J, you can register device callbacks, and execute ADB commands in a Java programming model. The library is written in pure Java and requires no additional dependencies.

Features

  • Perform ADB commands using Java code
  • Register device callbacks
  • Pure Java implementation with no external dependencies
  • One device per thread model

Quick Start

Maven Dependency

Add the following Maven dependency to your project:

<dependency>
    <groupId>com.github.magicsih</groupId>
    <artifactId>adb4j</artifactId>
    <version>0.0.1-SNAPSHOT</version>      
</dependency>

Example Usage

Here is a simple example demonstrating how to use ADB4J:

AdbContext adbContext = new DefaultAdbContext(
    Executors.newFixedThreadPool(10, new CustomizableThreadFactory("ADBNetwork-")),
    Executors.newFixedThreadPool(10, new CustomizableThreadFactory("AdpcCallback-"))
);
adbContext.init();

String packageName = "com.sec.android.app.clockpackage";

AdbDevice s8 = adbContext.getAdpcDeviceById("{your-android-device-id}");
s8.registerPollingListener(STAT_INFO_TOP, "top -p `pidof " + packageName + "` -o ARGS,%CPU -n 1\n", this, false);
s8.registerPollingListener("meminfo", "dumpsys meminfo " + packageName + "\n", this, false);
s8.start();

Thread.currentThread().join();   
adbContext.shutdown();

About

"Java-based Android Debug Bridge library for executing ADB commands, registering device callbacks, and more. No external dependencies required.

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages