I want to toggle the the mobile data button that can be seen when you pull down the menu strip. I have tried a couple of examples, but none seem to work. (How to disable Mobile Data on Android as an example). Is this simply not possible and if it is not possible, how would I go about disabling all connections?
First of all you might check the status of mobile data and consequently enabling or disabling them.
To check the status see this answer and to toggle the data see this.
Remember to add to the manifest all permissions and keep in mind that this method is no longer available on android 5 (Lollipop).
Related
I am building an app which runs in the background and I want to display a short text but only when for example the user is checking images on Instagram. So I need to check if Instagram is in use and then put the message in some kind of if statement.
How do I check if a specific app is currently used in the foreground? I searched around but can only find old posts with codes that are not supported anymore.
I am new to building apps so can someone please explain me how to accomplish this?
quick Android Development question on how to Code something!
I've searched for it, but the results are always messy, so I cant seem to find what I need.Any help is greatly appreciated..
Question:
How would I write the Code to: Turn the user's "Location" Setting to "OFF"..?
For example, in the same way that all of the "settings toggle buttons" homescreen widgets would do it, I assume - although i'm implementing it differently than that.I simply just need the raw code that turns LOCATION to OFF.
Also, what permissions would I need to add in my Manifest?
THANKS IN ADVANCE! :)
How would I write the Code to: Turn the user's "Location" Setting to "OFF"..?
You don't, except perhaps on rooted devices or as a system app (i.e., pre-installed by the manufacturer). Ordinary apps have no ability to change the user's location settings directly.
all of the "settings toggle buttons" homescreen widgets would do it
Only on rooted devices, or those that are supplied by the device manufacturer for their device.
I saw new Android devices coming out, that show things (clock etc.) once the display "turns off". That feature is called an Always-On Display, and since my Samsung Galaxy S6 edge already features an AMOLED screen, and a night-clock, I believe there is a way, to make it show something, when the display is "turned off". Is there a way using Java on Android, to display something, once display is meant to turn off? (Like just a normal GUI, I could do the rest then.)
Like, to tell your app, to show something, when the screen turns off, that is still visible somehow? (without root permissions)
That would be useful, thanks in advance.
UPDATE:
I found some apps on the Google Play Store, which seem do to, what I want (not that specialized though):
https://play.google.com/store/apps/details?id=com.thsoft.glance&hl=de
https://play.google.com/store/apps/details?id=com.orthur.always_on_display&hl=de
So it is definetely possible, I just need to know, how.
If you are not using root, then you can only use the Android APIs. Here is a list for example for the display: http://developer.android.com/reference/android/view/Display.html
I don't see anything there for the Ambient Display mode or Always-On.
Samsung provides APIs also for the features of it's phones here: http://developer.samsung.com/galaxy Here I can find the Look API that has something close to what you want, but for Edge.
I have a mobile phone with dual sim. If I want to turn on Airplane mode, its happening for both sim.
Is it possible to do for only one sim (user can select the one of the two) programmatically? I saw the posts over here, that they work till API 16. Any other work arounds?
As I can see this in the docs:
Some device settings defined by Settings.System are now read-only. If
your app attempts to write changes to settings defined in
Settings.System that have moved to Settings.Global, the write
operation will silently fail when running on Android 4.2 and higher.
Even if your value for android:targetSdkVersion and
android:minSdkVersion is lower than 17, your app is not able to modify
the settings that have moved to Settings.Global when running on
Android 4.2 and higher.
They say Settings.System are now read-only, but reading these blogs,I don't need your permission!, which explains how to skip the permissions part, by this way we can ask the user to give permission to turn on/off the airplane mode and escape the permission issue mentioned here?
Thanks in advance.
Is it possible to do for only one sim (user can select the one of the two) programmatically? I saw the posts over here, that they work till API 16. Any other work arounds?
There's no official Android API which supports this. Additionally, I'm not aware of any vendor/device specific SDKs which provides such an API.
They say Settings.System are now read-only, but reading these blogs,I don't need your permission!, which explains how to skip the permissions part, by this way we can ask the user to give permission to turn on/off the airplane mode and escape the permission issue mentioned here?
The example in this blog post has nothing to do with airplane mode.
Edit: Please also note that airplane mode isn't related to the SIM cards but to the connectivity hardware, e.g., Wi-Fi, Bluetooth, or cell radio modules. Thus, when enabling airplane mode this hardware is turned off. Depending on the device only one cell radio module might be built-in which would make it impossible to restrict airplane mode to a single SIM card.
I have an application (however I'm testing using the sample bluetooth chat from the SDK) where two android devices connects each other, and exchange data.
I already have part of the pairing process hardcoded using the BT address, problem is: the dialog it appears to confirm the pin. Is there a way to make that work programmatically? The only thing that "appeared" to solve my problem was in this question, but that API is completely abandoned, has no documentation and many issues.
As fair as I know the problem is that if the device is not the device database with paired devices, without root access the standard API is always going to prompt the user, but I'm still wondering if there's a way.
Bluetooth autopairing is defined only for some devices. To change this you should rewrite Android framework. So, from the application, it seems to me, this is impossible to do.