I have a large number of activities each calling some of the other and I am getting really confused as to which activity is calling which other activity . Show call hierarchy in eclipse does not show me this. Is there any way I get to see from where a current activity is being called.
You can check what the current Activity Stack looks like using ADB.
In Linux, you can use:
adb shell dumpsys activity | grep -i run
This will give you a nicely formatted hierarchy of currently running Activities.
EDIT: I'm assuning you have ADB in your PATH. If not then you'll have to specify the full path to adb (which is located in the android sdk folder).
I'm not sure of a completely work-free method, but you could do intent.putExtra("source", TAG) in all the places where you do createActivity() and then Log.d(TAG, "Intent started from: " + getIntent().getStringExtra("source", "unknown")) in all your onCreate()s.
Or, on a Windows machine:
C:\Program Files (x86)\Android\android-sdk\platform-tools\adb shell dumpsys activity | find /i "run"
Modify the path to adb.exe, if needed
Related
I have learned that using the ADB one can force the layout guides to show using the following commands:
adb shell setprop debug.layout true
adb shell service call activity 1599295570 # SYSPROPS_TRANSACTION
This allows developers to see the layout grid thanks to the SYSPROPS_TRANSACTION code.
The examples of which can be found here
However if I want to change something like RTL (right to left) - the SYSPROPS_TRANSACTION call does not force the re-render, I suspect because it needs to restart the activity, given that a rotation of the device will work:
adb shell setprop debug.force_rtl true
adb shell settings put system user_rotation 3 # landscape
adb shell settings put system user_rotation 0 # portrait
While I don't mind invalidating the activity I don't think I should have to be this "manual" about it. Is there a mechanism to refresh the screen without doing the rotation?
I have looked in the AOSP and found this:
private void writeToForceRtlLayoutSetting(boolean isEnabled) {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RTL,
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
DisplayProperties.debug_force_rtl(isEnabled);
}
which is roughly the equivalent of:
adb shell settings put global debug.force_rtl 1.0 #or 0.0 for off
But I have noticed if I do this one and a rotation it does NOT change
I have been trying to find the appropriate broadcast intent so that it would work, but I can't find one that just tells the screen to re-render
adb shell am broadcast <SOMETHING HERE WOULD BE NICE>
I took a page out of the DarkModePreference and tried to tell it that the battery charge state had changed, but you can't do that from ADB:
adb shell am broadcast android.os.action.POWER_SAVE_MODE_CHANGED
But no luck there either - no refresh happening
NOTE:
It's interesting that the layout bounds and RTL elements are grouped in the android source code, yet don't use the same behaviour when changed
I noticed that if I use
adb shell wm size
I can read the size of the window, and as a bonus, when setting it, it causes a redraw regarding right to left. So now what I do is read the window size, save it, change it a little, set it to the changed value and set it back. My script looks something like:
run("adb shell settings put global debug.force_rtl 1.0")
old_size = run("adb shell wm size")
run("adb shell wm size 100x100")
run("adb shell wm size " + old_size)
And it will force the right to left. It's a bit hacky but it works.
When creating an avd, starting it for the first time and then trying to close the emulator, the user will be prompted with a dialog reading:
Do you want to save the current state for the next quick boot?
Note: Saving the snapshot may take longer because free RAM is low.
I would like to save this parameter, before starting the emulated device, within its config.ini file.
However I'm not clear on which option it is.
Things I tried:
Adding these lines to the config.ini
fastboot.chosenSnapshotFile=
fastboot.forceChosenSnapshotBoot=no
fastboot.forceColdBoot=no
fastboot.forceFastBoot=yes
Creating an additional file within the config.ini directory of the avd called quickbootChoice.ini that simply reads:
saveOnExit = true
Non of which helped, on every first shutdown of the emulated device this dialog pops up...
Thanks in advance
According to https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/android/android-emu/android/skin/qt/tool-window.cpp the popup does not appear if the method returns based on this:
if (saveOnExitChoice == SaveSnapshotOnExit::Always &&
(fc::isEnabled(fc::QuickbootFileBacked) ||
(!savesWereSlow && !hasLowRam))) {
return true;
}
Setting QuickbootFileBacked = on in .android/advancedFeatures.ini fixed it for me. See https://androidstudio.googleblog.com/2018/08/android-emulator-28.html.
You can configure this setting in Android Studio, see this answer for instructions: Android emulator - Don't save state by default
If you are starting the emulator from the command line. Then provide the -no-snapshot-save parameter, to prevent it from saving.
emulator #Nexus_5X_API_23 -no-snapshot-save
reference: https://developer.android.com/studio/run/emulator-commandline
I am creating a GUI to launch various applications from the click of a button. To save me from having to open them all up manually.
I am currently trying to launch an Android emulator, I can do this with the following command: emulator #Nexus_5X_API_22 ...pretty simple.
I am trying to do this in python using:
subprocess.Popen(["emulator #Nexus_5X_API_22"],shell = True)
However, nothing seems to happen when this is called. A print statement returns '127', not sure what that infers?
What am I doing wrong?
-----------EDIT-----------
here is some code, I am using Kivy.
class RunTests(Screen):
def __init__(self,**kwargs):
super(RunTests,self).__init__(**kwargs)
layout1 = StackLayout(orientation='lr-bt')
runbutton = Button(text='run all', size_hint=(0.8,0.05))
runbutton.bind(on_press=self.runAll)
layout1.add_widget(runbutton)
self.add_widget(layout1)
def runAll(self,*args):
subprocess.Popen(["emulator", "#Nexus_5X_API_22"])
The problem is that you didn't separate the parameters into separate items in the list. Because you said "shell=True", subprocess tried to run a program called "emulator\ #Nexux_5X_API_22". Separate out the parameters and skip the shell
subprocess.Popen(["emulator", "#Nexus_5X_API_22"])
Ok, so #Youn Elan suggested using the full path.
subprocess.Popen(['/Users/User/Library/Android/sdk/tools/emulator -netdelay none -netspeed full -avd Nexus_5X_API_22'],shell=True)
this does work.
I am making a simple GUI program to change bootanimation of a android phone but from last 4 days I am facing a problem and I don't know whats is reason, here is my code
void MainWindow::bootanim1()
{
QProcess rootboot;
QStringList path6,boottarget;
path6<<ui->lineEdit_6->text();
boottarget<<path6<<" /system/media";
ui->textBrowser->clear();
ui->textBrowser->setText("Remounting partitions...");
rootboot.start("bbin\\adb shell su -c \"busybox mount -o remount,rw /system\"");
rootboot.waitForFinished();
ui->textBrowser->setText("\nInstalling bootanimation.zip");
rootboot.start("bbin\\adb push ",boottarget);
rootboot.waitForFinished();
ui->textBrowser->setText("\nBootanimation has been changed! Try shutting down your phone to see new bootanimation");
}
This function is launched when a button is clicked but my problem is, this is not working! Secondly you can see in the code that to be more informative I have used a textBrowser to show user whats going on like Remounting partitions etc and the lineEdit_6 is the lineEdit widget where user will paste the path of the bootanimation.zip. So my problem is when I click the button only this is shown
Bootanimation has been changed! Try shutting down your phone to see new bootanimation
And everything above it I think is getting skipped, I don't know why? can anyone give me some hint on what I am missing?
Here you are mixing two different methods to give arguments to QProcess:
boottarget<<path6<<" /system/media";
rootboot.start("bbin\\adb push ",boottarget);
First method gives the program name and arguments in one QString.
Second method gives the arguments in a QStringList.
You are trying to give one argument ("push") in the program name string. It doesn't work, when the other arguments are given in a QStringList. The last argument also contains suspicious looking space in the beginning, although I don't know if it causes problems. Try this instead:
QStringList args;
args << "push" << path6 << "/system/media";
rootboot.start("bbin\\adb", args);
And path6 variable probably should be QString instead of QStringList.
Ui requires eventloop to refresh itself. When you do all changes in one function call, then only internal property change, and gui itself doesn't repaint. Use QCoreApplication::processEvents(); right after each ui->textBrowser->setText(...);
Is there any way to switch on wifi in monkeyrunner otherthan using the cordinates.?Can we use WifiManager api from monkeyrunner.
from android.net.wifi import WifiManger
is working after copying android.jar file to tool/lib location.But how to invoke the WifiManger methods inside a android fon using monkeyrunner/monkey..??Somebody please help.
You can switch on the wi-fi by another way. Start the activity of settings and go to the "wireless & network settings" and enable it.
Following code is the start the activity of the settings:
# sets a variable with the package's internal name
package = 'com.android.settings'
# sets a variable with the name of an Activity in the package
activity = 'com.android.settings.Settings'
# sets the name of the component to start
runComponent = package + '/' + activity
setting = 'com.android.settings.Settings'
print("")
print("")
print("Start the Activity...")
# Runs the component
device.startActivity(component=runComponent)
After that by the press event use 'DOWN' and 'ENTER' KeyCode and you can enable the wi-fi...!!!
I looked into this exact issue a few months ago. It did not seem possible to me; at least easily. The best way I could find was to use startActivity to get as close to the wi-fi settings as possible, and then program in D-PAD commands until the correct field was highlighted. You may be able to use this logic to develop a small, purpose build, app that onCreate or onResume toggles wi-fi. In my case, it was not worth the amount of time this would have taken.