This test rule is now in the 'test-rules' support repository. Use that one!
https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html
/* | |
* Copyright (C) 2013 Google, 2014 Stefano Dacchille | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This test rule is now in the 'test-rules' support repository. Use that one!
https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html
import com.google.common.cache.Cache; | |
import java.util.Map; | |
import java.util.concurrent.ConcurrentHashMap; | |
import rx.Observable; | |
import rx.subjects.BehaviorSubject; | |
import rx.subjects.PublishSubject; | |
import rx.subjects.Subject; |
/* | |
* Copyright (C) 2015 Jake Wharton | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
import android.app.Activity; | |
import android.support.annotation.Nullable; | |
import android.support.test.runner.lifecycle.ActivityLifecycleMonitorRegistry; | |
import java.util.Collection; | |
import static android.support.test.InstrumentationRegistry.getInstrumentation; | |
import static android.support.test.runner.lifecycle.Stage.RESUMED; | |
public final class CurrentActivityUtil { |
As it turns out, it is not trivial to control the audio volume of an Android device using ADB. At the time of writing, the only way appears to be using the service
tool. Actually, the service
command allows to "connect" to a number of services (104 on Android 6.0.1) and invoke functions. Not knowing much about this tool, I managed to completely mute all sounds and speakers of my Nexus 5, and I was stuck without any sound for quite some time. I did not find a way to unmute the sound from within the system UI, so I got to dive a little deeper into this.
If you know which service you want to use, you then need to find its interface declaration. The command
service list
gives you a list of all services with the associated interfaces, if applicable:
...
26 backup: [android.app.backup.IBackupManager]
Android Emulator (ARM64) on EC2 - 2022 | |
--------------------------------------- | |
1. Launch EC2 ARM based Instance (a1.metal / a1.2xlarge): (16 Gb RAM, 32Gb Disk), Ubuntu Server 22.04 LTS (HVM) ARM x64 | |
2. sudo apt update && sudo apt upgrade | |
3. sudo apt install default-jdk python3-pip repo python-is-python3 unzip libpcre2-dev adb | |
4. wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip | |
5. unzip commandlinetools-linux-8512546_latest.zip -d android-sdk | |
6. sudo mv android-sdk /opt/ | |
7. mkdir /opt/android-sdk/cmdline-tools/latest | |
8. mv /opt/android-sdk/cmdline-tools/* /opt/android-sdk/cmdline-tools/latest (ignore the error) |