So I am trying to set up a system for multiple phones being connected to a device that handles phonecalls. In order to do so, I've been investigating the getUserSelectedOutgoingPhoneAccount() method, which should help me differentiate between the phone making the calls and the rest of the phones that are connected.
However, when I try to use that method with my instance of a Telecom Manager, it does not appear in the list of callable methods. I can see things like "getDefaultOutgoingPhoneAccount()" and "getCallCapablePhoneAccounts()", but nothing about getting or setting the user's selection. According to the android documentation, it's public and callable from a Telecom Manager. This manager is already set up in such a way that it can make phonecalls and such just fine, so I assumed this method would appear.
EDIT: This is how the telecom manager is initially defined; could this be why I'm not able to use the method in question?
Should I use a new telecom manager instance? Is it possible I'm missing something else, like an import? The current import for Telecom Manager is "android.telecom.TelecomManager".
Answer:
After looking into it some more, it appears my application is running on a lower API Level than this method has been implemented in (Android 8.1.0, which is API Level 27). This method requires API Level 29 or higher in order to call it.
Related
My (Android) app needs a network scanner feature.
I want to give it a subnet and I want it to send a request to each possible address on the subnet and determine whether or not it's responsive.
I have two classes:
Device, which contains an address and a property available (bool) (that can be set by the method checkAvailable).
NetworkerScanner, which extends Thread and instantiates all the Devices.
Eventually, I plan to have an object that is an observer on an Observable collection that will contain all the available devices.
Adding the available Devices to the Collection is not obvious.
Algorithm
Let col be a Observable Collection
For each possible address
Instantiate a corresponding Device
On a new, separate thread, get this new device's availability.
If it's available, then add it to col.
Checking device's availability is not immediate (I'm using Volley, which uses callbacks).
How can I, from my HTTP request callback, add the Device to the collection?
I have several ideas:
Pass a reference to the collection to the device when instantiating it, which seems like a bad idea, since the collection doesn't have a reason to be a property of the Device. More than that, if I wanted to run multiple scans on the same Device instances, it wouldn't work anymore since a Device could only have one Collection.
I could also pass a reference to the collection to the checkAvailable method, but I feel like this is a trick (and a trick of the wrong type of tricks).
When calling checkAvailable, pass a reference to an onResponseListener (the callback method for the HTTP request) to it. Since I would have created the listener in my NetworkScanner, I could capture the local collection. But I feel this is wrong. Like... very wrong.
Please suggest.
I was looking at the new APIs introduced in Android 2.2. While looking at the ActivityManager class I came across the following method:
public static boolean isUserAMonkey()
Used to determine whether the user making this call is subject to teleportations.
Returns whether the user making this call is a monkey.
How and when should this be used?
as per android docs
Returns "true" if the user interface is currently being messed with by a monkey.
to know the application is testing using monkey or not
well if you do some automatic testing there will be test users. this method checks if the current user is such a test user.
about how to use it there are already a lot of topics, see:
clickMe
I want to create a program for Android which picks up automatically when a certain number calls and answer with dtmf tone. Is this possible in Android Java?
If you just wanted to be aware that a certain number had called and then do some non call action, such as log the call, send a notification to a server etc then you can simply use the Android TelephonyManager () and create a BroadcastReceiver to listen for incoming call events. There are quite a few examples of how to use it to detect incoming calls available with a quick search.
If you want to actually answer the call then strictly speaking in 'standard' Android terms you can't. However, take a look at this excellent answer (not mine...) for some workarounds which may possibly work for you depending on your particular solution (whether your target devices are rooted etc):
https://stackoverflow.com/a/27084305/334402
Background
So I've inherited an android application that in various places connects to web services to send or receive information.
As it is right now, when a connection fails the user of the android device is prompted with an error message that for most users are viewed as obscure.
The problem
So what I'm looking for is a pattern or suggestion on how to implement a solution in this android application that catches all java connection exceptions and presents a dialog telling the user he lost the internet connection and needs to try again.
Any ideas? :-)
Edit, current idea
My current idea to solve this issue, or making it a bit more managed instead of having a fractured exception handling that takes care of the problem at every possible connection is this.
Each communication instance/class will inherit from a super class, or implement an interface that forces this class to be used. This class contains the logic for connection exceptions. Lets just for now call it ConnectionExceptionManager.
The problem then only becomes implementation of this in each communication class in each web service call. In each web service calls exception I need to check for communication exceptions and if it hits, use the ConnectionExceptionManager in this catch.
This would however still make it a hassle, to copy into request method in each communication class.
Any ideas about improving this current idea of mine?
What I understood from your question is that you need to check internet connectivity before performing any internet related action. For that you can simply create public static boolean function i.e. public static boolean isInternetConnected(){...} in global class so that you can reuse your function.
If you want your application to check internet connectivity automatically then you can use IntentService which will work in background and in its protected abstract void onHandleIntent (Intent intent) you can check isInternetConnected() returns true and if not then you can open AlertDialog.
To use this background service after repeated intervals while application is running, you can use AlarmManager.
Hope this helps.
I am am new to mobile app development. But i would like to know if this is possible to intercept incoming calls on my N73 using code like Java or C++?
My second question is if this is possible then can we prevent the phone from ringing with a specified phone number from a black listed contact???
I've seen a lot of apps doing this task but i am interested in knowing if this is feasible & how this is accomplished.
Thanks in Advance.
In C++ you can use CTelephony from etel3rdparty. Use NotifyChange() to subscribe to EVoiceLineStatusChange events. On an EStatusRinging event you can call GetCallInfo() to retrieve the remote party information, including phone number, and then decide whether to reject the call or let it keep ringing.
As far as I know, the CTelephony API does not have a direct method of rejecting a call but you can achieve almost the same with AnswerIncomingCall() followed by HangUp(). Your executable will need the NetworkServices capability.
A more hackish way to reject the call could be to use RWsSession to simulate pressing the red key (end key): call SimulateRawEvent() to send TRawEvent::EKeyDown and EKeyUp events on EStdKeyNo, with some delay between the events. In this case your executable will also need the SwEvent capability.