I have a dual-sim Android phone and during the morning I use one of the SIM cards for the data connection, and during the evening I use the other one. It's a pita to manually switch from one card to the other twice every day, so I thought I could create a simple app that does the switching at a given time.
I've been reading and looks like starting at version 5.1 of Android's API, theres a SubscriptionManager class which offers info about current subscriptions (data, voice, sms, etc), but as far as I've seen there're a lot of get methods but no setters anywhere.
Does the Android API offer a way of setting the SIM card used in the data connection? I guess it does, because otherwise it wouldn't be possible to change it from the settings panel.
Related
I want to have one stationary device like an android phone that can use a standard local SIM card and forward all calls to a second device over some kind of VoIP protocol. When someone calls the phone number of the stationary device, I want my second device to ring and handle the call through something like linphone, element, or whatever. Ideally, it should be possible from the second device to initiate a call from the stationary device's phone number as well. Bridging SMS too would be nice, but I already have a solution for this on android.
There are many use cases like
when traveling abroad, being able to bring the latter device and receive/make calls via the stationary device at home
forwarding multiple phone numbers to a single device and e.g. switching off the work number when away from work
having privacy when the location of SIM cards is logged, by making calls over wifi from somewhere else than the stationary device
when traveling somewhere with bad mobile coverage but available wifi, without having to think about how the second device handles it
Are there any existing projects for doing this?
If not, then what would be necessary to make something myself? Is the best solution something like connected an android device by bluetooth to something running asterisk like was discussed here? Or has something changed in the past 11 years, maybe the existence of some working linux phones makes this possible on a dedicated purism or pinephone device?
I think you can achieve this with Brekeke SIP Server. I am using their solution to achieve something similar to what you want to do.
there are multiple ways to achieve it technically, but the most practical solution to your use case will be to use a VOIP Gateway device.
Actually we can not use a mobile phone as gateway between SIM and VOIP calls.
so you can buy a voip gateway example GOIP (single SIM) and put your sim, connect to your home internet and configure. your phones softphone (eg linphone) will be able to directly register on it and you will be able to make/receive calls and sms.
there will be a new problem as mobile OS platforms are more and more restrictive about power, your sip client will not be able to receive calls while in background for that you will need push, so you can use twillio's mobile sdk to make a client that works fine then forward your calls to twillio from gateway. since there is no number or telecom services involved, cost on twillio should be minimal.
A more common way to do this is with an operator service, rather than implementing it yourself.
The operator is able to see the routing to your number and simultaneously call multiple numbers you have set up. Different operators will have different names and details so you would need to speak to your local operator.
For example BT in the UK (who I have no affiliation to - just an example) provide a service called 'Follow ME': https://support.ringcentral.co.uk/s/article/9010?language=en_GB
If you do want to do it yourself than an open source PBC like Asterisk is indeed a good starting point.
I have a feature where I need to fetch current AND detect switch of the active audio output device of the system. Something like:
run app -> fetch current device (which might be embedded speakers)
connect bluetooth speaker -> detect switch to bluetooth speaker
connect audio jack -> detect switch from bluetooth speaker to audio jack
It seems to me there should be one API for this but it seems there are several. The one that makes the most sense seems to be MediaRouter but there are two large issues with it that prevent me from using it as described above:
There are at least 2 scenarios in which it fetches the wrong device as the active route and on other scenarios it straight up doesn't detect route switches at all. For details on this please check out the ticket I opened on the google issue tracker
I need certain information on the current active output device, most importantly a universal identifier. For bluetooth devices, the Complete Local Name can be used for this, which is available from BluetoothDevice types but this is not obtainable from the MediaRouter. Instead, MediaRouter makes a productName available, which sometimes can be an alias of the bluetooth devices, and not the static name.
I have since abandoned this API and moved on to find other solutions, let me know if anyone thinks there's a way around the problems above, most importantly the first one. I will note that I have used both the android.media.MediaRouter and the androidx one, they both have these issues.
I am now leveraging a combination of other APIs. It works but it is a far from acceptable solution:
Using AudioManager.registerAudioDeviceCallback(object : AudioDeviceCallback) for non-bluetooth devices detection (AudioDeviceInfo.TYPE_WIRED_HEADPHONES, AudioDeviceInfo.TYPE_BUILTIN_SPEAKER)). I'm getting callbacks when any of these devices get added or removed and then I can check if a wired type device is present then that's the active one 100% of the time, if it's not, then the embedded-type is active. It's kind of hacky but it works.
More interestingly, for detection of Bluetooth output devices I use a private API, that Android itself uses in the Settings app to display the current audio output device.
BluetoothA2dp::class.java.getDeclaredMethod("getActiveDevice") to get the current active output device. This is done by getting the profile proxy service bluetoothAdapter.getProfileProxy
register a receiver for this action BluetoothA2dp::class.java.getField("ACTION_ACTIVE_DEVICE_CHANGED").get(null) in order to detect switches of the bluetooth active audio device.
This solution works but also has a few limitations:
they are obvious private APIs, subjected to sudden change and potential breaks
the active device APIs mentioned above are not available < Android 9. I have yet to investigate what Android is using pre-Android9 in the Settings app
On Samsung devices the active device API works incorrectly.
So, the million dollar question. How do I fetch and detect the current audio route on Android, reliably?
So I am making a project for my android class at school.
The project is about helping handicaped people communicating with a nurse if they can't speak. The solution I've come up with is an app where 24 pictures is combined with 24 sound files which the user then can use to communicate. For example, by taking a picture with a helper and then the nurse records the word on a tablet then when next time the user needs to get an apple he/she just presses the apple on the app and it says apple.
What would optimize this app would be that instead of each user of the app having a tablet, the nurse only has one. Then when entering the house of a user he/she can by scanning a NFC chip, get the pictures and sound files into the app belonging to that person.
So here's the question. Can this be done by combining a NFC chip with some sort of SD card solution or will this have to be done by the chip returning for example an URL with some sort of user parameter getting the pictures and soundfiles by using an internet connection?
So is there some storage thing you can put together with an nfc chip that could make this posible?
I am new to android and I want to implement finding the location of another phone and displaying their location on my device using Google Maps while I am talking with that person.
Considering the fact that currently I'm not aware of a phone carrier company providing an API over the cellular network or a server to access other phones' locations, you'll have to implement the infrastructure yourself.
By that, I mean both the on-phone applications designed to transmit and receive location data and the means to communicate this data between phones, when a call is placed.
It would be easier at this point if you could programmatically embed metadata in the caller id information of calls you place from an Android phone, but unfortunately I don't think that such an API exists at the moment.
This leaves you with only two other options: have the application on the caller phone send the location data either through a server that you control, or through an SMS message to the number it's calling.
Using a server only works if both phones are connected to the Internet, so you must rely on data traffic to work for the location data to be transmitted.
Sending location data by SMS incurs some kind of cost for your user, as it either subtracts from the available number of SMS messages included in their carrier plan, or simply charges them extra if this plan is already over capacity.
You may offer a clear alternative, that the user should be informed about, to use one way or the other; depending on the application's scope and purpose, each of these alternatives may be suitable (I'm thinking of this feature only activating for some specific phone numbers, in case you'd use this app inside a company that deals in on-site interventions to some kind of emergencies, that require automatic location reportning at the time of certain calls from the field).
You have two options - both of them probably not so feasible:
1. Having an application running on the other phone which is designed to transmit the location to wherever needed.
2. Having the phone carrier company(s) providing you either an API over the cellular network or via their server an access to the other phone's location.
Good Luck
Suppose I want to run some program which requests too many permissions. For example, record from the microphone or read IMEI of my phone. However, there are no practical explanation why recording from the mic or IMEI number is needed for this particular application, except for data mining.
I want to try this app, but restrict its permissions. For example, if it reads IMEI, it should get random IMEI(but the same every time). If it tries to read the mic, it should get silence.
Some other interesting permissions:
Phonebook read/write access -
returns zero contacts, pretend that
write is OK, but actually do
nothing.
Send SMS - pretend that SMS
is sent, but do nothing.
Get list of
visible Wi-Fi networks - return zero
networks.
Obviously the tool should require a rooted phone. Are there any such tools?
You could download the Android SDK and use an emulator to test our the applications. You could then set info like your phone book and test out how the app is using that data.
There is a TISSA prototype application, but it is not released, yet. In CyanogenMod 7 there is a setting to revoke application permissions, but if the app expects the API to return something useful instead of failing, it will crash, it is still not faking data.
i just found the free LBE Privacy Guard for rooted phones. It pretends to protect sms, Internet access, contacts, Call Logs, Positioning, Phone ID, Phone Call and phone state.