code to enable a setting of Android developer mode [duplicate] - android

This question already has answers here:
How to access device settings programmatically?
(6 answers)
Closed 6 years ago.
I want to make a code to enable the developer mode and set a parameter on this ( the one to always allow roaming detection so we can switch to a better wifi if found).
I saw some apps that can launch developer mode, but nothing is opening it AND changing some parameters. I can't ask to users to set this parameter themselves, so how can I make this myself?
I saw also that we can do this by shell :
adb shell am start -n com.android.settings/.DevelopmentSettings
But afterwards i don't know how to set automatically a parameter.
As I made my own app, I could launch developer mode and this param on the start of my app.
Did anyone made this before inside of an app?
How can I call DevelopmentSettings activity inside my app and edit some of its parameters?
Thanks
EDIT
I can eventually root all my phones and set my app inside system folder, It can be complicated but we could manage it. If I does, How can I access to the parameters of developer mode programatically?

You can use following code but you need root access for this.
.Settings.Secure.putInt(getActivity().getContentResolver(),Settings.Secure.ADB_ENABLED, 1);
For More information
Check this link :
How to access device settings programmatically?
Thanks

Related

How to access Android hardware by pressing volume key [duplicate]

This question already has answers here:
Listen to volume buttons in background service?
(14 answers)
Closed 5 years ago.
I am making an application and I want to make app in such a way that user directly open that by using volume key, suppose user click twice the volume+ or volume- buttom and the app will directly open without home screen or without any interuption.
I want to add this functionality using the code in Android Studio. If anyone know how to add this, please help...
What you are asking for is not App/Code nor Android Studio related but device related, If the Original Equipment Manufacturer will allow a device to have a shortcut button it could be possible to achieve that on those devices.
Cheers.

add another app inside my app?

my goal is to get a video from a usb connected device (an easycap video grabber) displayed. There is already an android app that does exactly that. However i need to add some buttons and some extra functions to it. So i came to the idea of displaying the app that already exists inside my app. Is that possible in any way?
I already tried to decompile the existing app to edit the code a bit but i didn't get anything to work with.
Do you have any other idea? If you know how to program that please let me know what i need to achieve that.
Thank you!
This cannot be done due to security reasons in the Android OS itself.
Android provides a security layer called the Sandbox in which the OS assigns a User ID for each app, so that an app will not have permission to access resources from another app.

Android: How to access display (Activity) of different app that is not shown in upper layer

Hello Android developers,
Im more or less expierenced in Android programming and now i want to create an app that is allowed to access the display of another app or the activity that is less my app. Both apps should be active, should run. My app shall access the display data of the other app (also can be android system display), change it a bit and then show it again.
Is it possible without root rights?
Is there any Android support class that could help me? Which way i can go?
I hope my problem is clear and you can help me!
Ok now I have a more detailed question: How can open my app and show a transparent RelativeLayout, so that you can see what is below my app?
Thankyou a lot
Martin
If both applications are yours, you can access the other Activity using a connection between them (sockets, pipes, shared files, etc.)
If you'd like to create an overlay and display something on top of the other app, you can do that using a 'system window' popup. For example: Popup window in any app
If the other app is an arbitrary software without any modifications, such thing is not possible as it would lead to security issues. Both applications are Unix processes running in their own sandboxes without any direct communication.

Is it possible to switch APN programatically in android?

I am trying to develop an app in which I need to connect to a specific APN programatically for network testing purposes.
As a user, I can do this by going to "Settings" -> "Wireless & networks" -> "Mobile Networks" (long press) -> "Access Point Names". It will even let me add a new one manually.
I want to know, is there a way an app can do that automatically? I have root permissions and everything you might need.
If anyone knows the android source, can you point me on where to look to study the behavior of this screen? I've tried to take a dive there but I'm kinda lost.
I'm answering my own question in addition to what was pointed by 7383. Hope this helps someone.
Similar to ApnEditor, I was actually looking for ApnSettings (link to cyanogen). I supposed this screen was provided by android and didn't suspect that "Settings" was actually an app.
The apps can't be used with an IDE as we usually do, it should be either compiled with makefiles like android or edit it's source so it's "ide-compatible" as suggested here
Now, to add or edit APNs you can't just put that code in any app. You need android.permission.WRITE_APN_SETTINGS which is a permission only available to system apps. The app won't be portable, but it appears this can be done using a rooted phone or a custom rom. More info here and here
I hope you are looking for this. The following links are from Android settings app source code.
add new apn
Set as default

Is it possible to click buttons on Android by ID via ADB and not just tap x,y locations or keys by their keycode? [duplicate]

This question already has answers here:
Is there a way to get current activity's layout and views via adb?
(8 answers)
Closed 4 years ago.
I write a testing automation for some android application and I want to tap on application elements like buttons by their ID, I know if it can be done by writing an android test application and install it on device (like Espresso, UIAutomator, etc...), but I don't want to use this approach.
Is there a way to do it from Android Debug Bridge? Maybe someone know some sort of tool similar to monkey-runner that can perform it? Basically what I ask - Is it possible to click buttons on Android by ID via ADB?
This is possible by using AndroidViewClient, and it is basically done by creating a python script and executing it. Note that this works best if these buttons contain some text or an ID to differentiate them from others. More information can be found here: https://github.com/dtmilano/AndroidViewClient/

Categories

Resources