Get current Activity name by adb shell

Here is the command:

adb shell "dumpsys window windows | grep -E 'mCurrentFocus'"

The output would be:

mCurrentFocus=Window{b6a99d1d0 u0 com.sec.android.app.launcher/com.sec.android.app.launcher.activities.LauncherActivity}

My activity name is: LauncherActivity

Resolutions and Densities – List

To change without root density and resolution on Your phone You can call in batch:

adb shell wm size {X}x{Y}
adb shell wm density {Z}

 

MODEL RESOLUTION DPI
Nexus 6 1440×2560 560
Samsung Galaxy S6 1440×2560 640
Samsung Galaxy Tab S2 8 1536×2048 320
Sony Xperia Tablet Z 1920×1200 240

To reset display call in batch:

adb shell wm size reset
adb shell wm density reset

I used information from application I’ve attachedĀ >>>HERE< <<

Connecting Nox with Android Studio

More info here: https://www.bignox.com/blog/how-to-connect-android-studio-with-nox-app-player-for-android-development-and-debug/

However If You created emulator from nox multiplayer (You can create android 5.1), make sure You have created shortcut to this device and runned by this shortcut.

The rest info related with enabling usb debug and setting to be executed with root permissions is the same.

Change time in genymotion emulator – simple java app

I made app in executable jar java file for setting time in genymotion emulator.

Here is simple java code and compiled app for setting time in genymotion app. Below code I showed how the app looks like and also added ready jar app to download.

Code:

public class SetTimeInGenyMotion {
private JTextField textField1;
private JButton getTimeInProperButton;
private JButton setTimeInProperButton;
private JButton getTimeAndSetButton;
private JPanel panel1;
public static final String FORMAT = "YYYYMMDD.HHmmss";

public static void main(String[] args) {
new SetTimeInGenyMotion().doStuff();
}

private void doStuff() {

getTimeInProperButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
textField1.setText(getTime());
}
});

setTimeInProperButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String time = textField1.getText();
setTime(time);
}
});

getTimeAndSetButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String time = getTime();
setTime(time);
textField1.setText(time);
}
});

showWindow();
}

private void showWindow() {
JFrame frame = new JFrame("SetTimeInGenyMotion");
frame.setContentPane(panel1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setMinimumSize(new Dimension(680, 0));
frame.pack();
frame.setVisible(true);
}

private void setTime(String time) {
try {
String command = "adb shell date -s " + time;

Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(pr.getErrorStream(), "UTF-8"));
String l = "";

while ((l = br.readLine()) != null) {
System.out.println(l);
}
br.close();

} catch (IOException e1) {
e1.printStackTrace();
}
}

private String getTime() {
//adb shell date -s YYYYMMDD.HHmmss
//http://stackoverflow.com/questions/7094772/how-to-set-android-device-date-time-programmatically

String format = "YYYYMMdd.HHmmss";
Calendar instance = Calendar.getInstance();
String time = getDate(instance.getTimeInMillis(), format);
return time;
}

public static String getDate(long milliSeconds, String dateFormat) {
// Create a DateFormatter object for displaying date in specified format.
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
// Create a calendar object that will convert the date and time value in milliseconds to date.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(milliSeconds);
return formatter.format(calendar.getTime());
}
}

Pic:
Zrzut ekranu 2015-06-03 11.58.59

Download:
download

How to run an android application using .apk file?

Here is the example how to run apk when you do not know what is the apk’s name.

First you need to call aapt to get info about AndroidManifest.xml from interesting apk. I will show you example on WifiKillDOwnloader.apk
In console you call:

aapt d xmltree WiFiKillDownloader.apk AndroidManifest.xml > manifest.txt

Console will output this:

Continue reading “How to run an android application using .apk file?”

adb command – reboot in specific device

First we need to know what devices we have by running command in console:
adb devices
[spoiler title=”Output”]

List of devices attached
01e010f522900141        device
192.168.56.102:5555     device

[/spoiler]

Or we can use with param -l for additional description.
adb devices -l
[spoiler title=”Output”]

List of devices attached
01e010f522900141       device product:occam model:Nexus_4 device:mako
192.168.56.102:5555    device product:vbox86tp model:Google_Nexus_7_2013___5_0_0___API_21___1200x1920 device:vbox86tp

[/spoiler]

And then when we know the specific address of our device, we can call to it our command for example:
adb -s 192.168.56.102:5555 reboot