Call Android Activity - android

I have an application that performs a phone call, but when I send dial directly, the application is in the background and displays the screen of the android default phone call, it must not happen, because when the phone call is made, I need to trigger commands that are in my application. If anyone knows of a possible solution. Thank you.
Below is the my method used to perform a phone call.
private void call() {
try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);
} catch (ActivityNotFoundException activityException) {
Log.e("Dialing", "Call failed", e);
}
}

Hope I got your question right. If you are trying to create an app to replace default phone call handling app, then I guess you should know that it's not a cake walk.
Firstly let me make it clear that you simply can't create a phone app to replace default app.
If you really want to do it then you need to get the Android source code, recompile it by adding your phone app and flash it on a rooted device.

Shortly, you cannot do "stealth" calls without dialer showing up.

Related

Is Android speech recognition service busy?

I use Android speech recognition service from my application.
It turns out that when two clients attempt to send requests at the same time (say, the user started one voice search from an app, then switched to another application while the search is still active, and launched another search), the service stops working.
Is there a way to determine that there's a voice recognition session in progress, so that I can refuse to start another one?
You should probably be trapping ERROR_RECOGNIZER_BUSY in the onError handler:
#Override
public void onError(int error) {
switch (error) {
case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
// do something reasonable
…
}
}
You're most likely (only?) going to receive that on a request to start listening; unfortunately, I'm not aware of any way to test this condition without trying (e.g. I don't think you can pre-detect another process's listener being active to remove a microphone button)
(On stopping listening, you'd only get this error if you were trying to kill another process's listener somehow.)
I was getting this error (ERROR_RECOGNIZER_BUSY) and found out that the package was missing in my intent set up. So I just added this line and it works now:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
...
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, context.getPackageName());

Android: make a call and disconnect after ringing to leave a missed call

I am using this code to make call
Intent callIntent = new Intent(Intent.ACTION_CALL,
Uri.parse("tel:" + phoneNumber));
startActivity(callIntent);
and I want to disconnect call after hear first ringing to leave a miss call on the destination phone.
I don't believe that's currently available in the Android sdk. I was trying to control outgoing calls on a project recently but other than dialing a number there's not a lot you can do. My last project needed to place a call, press a button, then hangup. For that I ended up setting up an Asterisk server that listened to a web page. You could do something similar but that would involve using a data connection to your own server.
You can check out these links. I don't like this answer but it's the way it is for now.
How to make a phone call in android and come back to my activity when the call is done?
http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL
If you want to step outside of techniques I would recommend check out the this answer.

What is the status of an outgoing call [duplicate]

Once ACTION_NEW_OUTGOING_CALL has been broadcasted, I need to capture the following event of the other party answer. Could you advice on how to achieve that please? I know it is possible as the Android dialer app changes the green Android icon to the person's photo exactly when they pick up.
UPDATED: I've had a look at the source of the app on Android handling the outgoing calls. I noticed the following method in ContactsUtils:
/**
* Kick off an intent to initiate a call.
*/
public static void initiateCall(Context context, CharSequence
phoneNumber) {
Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
Uri.fromParts("tel", phoneNumber.toString(), null));
context.startActivity(intent); }
I guess my answer is in the activity listening for Intent.ACTION_CALL_PRIVILEGED. So to rephrase my question: Does anyone know which activity handles Intent.ACTION_CALL_PRIVILEGED?
I don't think there's such API and also there's no API for sending DTMFs due to the same reason that you can't tell when the call is being connected.
It does not necessarily needs to be possible to capture this as an outside app. The green android icon is a part of the application that controls the call, so it does not need a broadcast to change the icon.
As far as android's telephony manager is concerned u cannot detect programmatically whether the call has been answered or not. This is to say that u do not have the option to know when the user picked the phone at other end.
Android has got 3 states of telephony manager and none of them are capable of detecting whether the call was actually answerd or not(IN CASE OF OUTGOING CALLS)
The only way you may be able to do this is by parsing the Logcat logs, no PhoneStateListener event is available for that.
Some are asking for it here: https://code.google.com/p/android/issues/detail?id=14266
Anyway, in versions above Android 4.2 as Logcat is "sandboxed" it may be impossible...

How can I detect when a call is answered? [duplicate]

Once ACTION_NEW_OUTGOING_CALL has been broadcasted, I need to capture the following event of the other party answer. Could you advice on how to achieve that please? I know it is possible as the Android dialer app changes the green Android icon to the person's photo exactly when they pick up.
UPDATED: I've had a look at the source of the app on Android handling the outgoing calls. I noticed the following method in ContactsUtils:
/**
* Kick off an intent to initiate a call.
*/
public static void initiateCall(Context context, CharSequence
phoneNumber) {
Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
Uri.fromParts("tel", phoneNumber.toString(), null));
context.startActivity(intent); }
I guess my answer is in the activity listening for Intent.ACTION_CALL_PRIVILEGED. So to rephrase my question: Does anyone know which activity handles Intent.ACTION_CALL_PRIVILEGED?
I don't think there's such API and also there's no API for sending DTMFs due to the same reason that you can't tell when the call is being connected.
It does not necessarily needs to be possible to capture this as an outside app. The green android icon is a part of the application that controls the call, so it does not need a broadcast to change the icon.
As far as android's telephony manager is concerned u cannot detect programmatically whether the call has been answered or not. This is to say that u do not have the option to know when the user picked the phone at other end.
Android has got 3 states of telephony manager and none of them are capable of detecting whether the call was actually answerd or not(IN CASE OF OUTGOING CALLS)
The only way you may be able to do this is by parsing the Logcat logs, no PhoneStateListener event is available for that.
Some are asking for it here: https://code.google.com/p/android/issues/detail?id=14266
Anyway, in versions above Android 4.2 as Logcat is "sandboxed" it may be impossible...

Detect if an outgoing call has been answered

Once ACTION_NEW_OUTGOING_CALL has been broadcasted, I need to capture the following event of the other party answer. Could you advice on how to achieve that please? I know it is possible as the Android dialer app changes the green Android icon to the person's photo exactly when they pick up.
UPDATED: I've had a look at the source of the app on Android handling the outgoing calls. I noticed the following method in ContactsUtils:
/**
* Kick off an intent to initiate a call.
*/
public static void initiateCall(Context context, CharSequence
phoneNumber) {
Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
Uri.fromParts("tel", phoneNumber.toString(), null));
context.startActivity(intent); }
I guess my answer is in the activity listening for Intent.ACTION_CALL_PRIVILEGED. So to rephrase my question: Does anyone know which activity handles Intent.ACTION_CALL_PRIVILEGED?
I don't think there's such API and also there's no API for sending DTMFs due to the same reason that you can't tell when the call is being connected.
It does not necessarily needs to be possible to capture this as an outside app. The green android icon is a part of the application that controls the call, so it does not need a broadcast to change the icon.
As far as android's telephony manager is concerned u cannot detect programmatically whether the call has been answered or not. This is to say that u do not have the option to know when the user picked the phone at other end.
Android has got 3 states of telephony manager and none of them are capable of detecting whether the call was actually answerd or not(IN CASE OF OUTGOING CALLS)
The only way you may be able to do this is by parsing the Logcat logs, no PhoneStateListener event is available for that.
Some are asking for it here: https://code.google.com/p/android/issues/detail?id=14266
Anyway, in versions above Android 4.2 as Logcat is "sandboxed" it may be impossible...

Categories

Resources