How to launch an Android SubSettings Fragment? - android

For example, how do I launch User Settings? It's not implemented as its own Activity, so I'm not sure how to start it.
Below are some other similar questions but these are either more general or more specific. My question is about starting an arbitrary SubSettings fragment.
How do I call a specific PreferenceFragment from a PreferenceActivity?
Show only wireless system settings on Android 3

You can launch most Android Settings sub-screens by starting the SubSettings Activity and including the :android:show_fragment extra with the appropriate fully-qualified class name of an existing Android PreferenceFragment subclass.
For example, to start UserSettings:
adb shell am start -n com.android.settings/com.android.settings.SubSettings -e :android:show_fragment com.android.settings.users.UserSettings
To start DeviceInfoSettings:
adb shell am start -n com.android.settings/com.android.settings.SubSettings -e :android:show_fragment com.android.settings.DeviceInfoSettings
These examples use 'adb shell am start', but in principle you could invoke these in Java code (EDIT: Unfortunately you need to be signed with the system key, otherwise you get a SecurityException). Notice that the key for this extra has a colon at the front of it. To find other Settings, checkout the Android source and look for subclasses of PreferenceFragment in the packages/apps/Settings.
The situation was different in Froyo and before. In those days Activities were used to implement Settings sub-screens, so one could launch directly into a sub-screen (for example SoundAndDisplaySettings) by the usual method of calling startActivity() with a ComponentName or action String. This mechanism still works for some Settings sub-screens. For example, to bring up a wifi picker, you can use
adb shell am start -a android.net.wifi.PICK_WIFI_NETWORK

for MM :
am start -n com.android.settings/com.android.settings.SubSettings -e :settings:show_fragment com.android.settings.applications.RunningServices

Related

I can't get the activity name using adb shell

I know that many people already sent questions similar to this. However, this is a little different.
I have to try to get the current activity from an android app, but it is not possible. Normally, I interact with the app and execute this: adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'. However, it always shows MainActivity. I checked the activity list on APK Info and this list is so little
So, there is some way to start a specific screen of apps similar to this?

Is it possible to start an activity via ADB without animation

I know it's possible to have no animation when starting an activity via code (here, for example), but is it possible to do so via adb too, even for activities that were supposed to have an animation ?
Also, is it possible to have no animation when going back from this opened activity?
Looking at the ADB Shell Activity Manager specification for arguments here: https://developer.android.com/studio/command-line/shell.html#IntentSpec
we can see that there is a -f option for Intent flags.
Th Intent flag FLAG_ACTIVITY_NO_ANIMATION has constant value: 65536
See: https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NO_ANIMATION
Putting that together you could write something like:
am start -a com.example.ACTION_NAME -n com.package.name/com.package.name.ActivityName -f 65536
you can use the below command to start an activity via adb,
am start -n yourpackagename/.activityname

Why can ADB start private components?

I understand that ADB is a powerful tool for development and testing purposes. But, I quite don't understand that how ADB can even start private components within my app that are not exported. For example, the following command shows how ADB can start an Activity within my app via explicit intent:
adb shell am start -n "<package_name>/.view.MyActivity"
MyActivity is only reachable through an explicit intent. In other words, there's no intent-filter tag defined for MyActivity in the manifest XML. On the other hand, I noticed that if start to launch a Activity which is public (meaning there's an intent-filter) and secured through a custom permission, ADB also can't start it and I get SecurityException (because ADB did't claim the permission?).

How to record the activity name via AndroidViewClient/Culebra

In order to shorcut and go directly to the current activity page of Android I must first find the activity name, if it is a fragment I try to get the closest activity as possible. I use a few commands to find this info, like "adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'" or "adb shell dumpsys activity top". Unfortunately it seems that "adb shell uiautomator dump" has only the package name of the current activity in the xml file, so it is not useful. Is that possible for Culebra to record the activity name of the current activity and generate it's associated code when it is an activity and not a fragment, something like device.startActivity(component='...') ? This would be very helpful and will permit the play back of the generated script directly from the activity.
I think your idea may be very helpful to others so I decided to add this functionality to culebra v 10.3.4.
The context menu, now includes Generates a startActivity()
which generates a line like this in the output script (considering that in this example Calculator was the Activity on top of the stack)
device.startActivity('com.android.calculator2/.Calculator')

How to get extras of currently running activity through ADB

I have a question about using ADB.
I know that this command:
adb shell dumpsys activity
can show me all the activities that are currently running on the device.
But I notice that sometimes, the intents appear like this:
Intent { ...some_intent/activity_name.... (has extras) }
I know that extras mean that the activity has been started with some sort of parameters passed to it (I may be wrong here, please correct me if I am).
So my question is, how can I get the extras of the intent/activity through ADB ?
The reason I need this is because I'm trying to launch an apk (that is installed on the phone) through ADB command, something like:
adb shell "su -c 'am start -n com.package.name/.ActivityName'"
That works and bring up the application. The application has a start screen (say we call it HomeActivity) and you have to click a button and make some selections (say SelectionActivity) and it will go to another screen (say ActionActivity). I want to be able to launch the apk and make it go straight to ActionActivity.
The application will crash if I try to launch the ActionActivity with am start command, I'm assuming this is because it requires parameters from the SelectionActivity screen.
This is why I'm trying to see what are the "extras" or parameters that the ActionActivity screen actually gets, so that I can do something like:
adb shell "su -c 'am start -n com.package.name/.ActionActivity -e param1 val1 -e param2 val2'"
Hope my question is clear.
Please correct me if I'm making a mistake somewhere.
Thanks in advance!
If I am understanding correctly, your target is to start the 'action' activity with correct intent but you don't know what kind of parameter information should be included, right?
The dumpsys command won't dump everything you want, so to simply achieve your target, you have 2 options (you should find one device which you can burn your own firmware into it):
Modify the dump method in AMS to print out more information
Modify the ActivityThread class source code to print out the detailed intent information

Categories

Resources