How to send DTMF tones in active call in android? - android

Is it possible to send DTMF tones in active call in android ? I tried it with proxyphone.sendDtmf() but it was useless.
How can i achieve it ?

In VOIP only it is possible,Android applications have no access to the in-call audio stream. You can fake a it a bit in speakerphone mode.

Try this method() .It is getting the number and delay from user.
private void call(int profileid) {//call procedure logic
ProfileDo profile = adapter.getProfile(profileid);
if (profile.getStepCount() == 0) {
Toast.makeText(getApplicationContext(), "Please edit the profile and add atleast one value to make a call", 10000).show();
return;}
String call = "tel:";
for (StepDO step : profile.getSteps()) {
String value = URLEncoder.encode(step.getValue());
int delay = step.getDelay();
String pausesStr = "";
for (int i = 0; i < delay / 2; i++) {
pausesStr += PhoneNumberUtils.PAUSE;
}
call += value + pausesStr;
}
startActivity(new Intent("android.intent.action.CALL", Uri.parse(call)));
}

Related

How do you synchronize android clients with a python server?

I have a python server and about 10 android clients, using sockets. It is really important that when the server sends a message, all clients receive it at the same time (say 1/10th of a second of difference).
But the connection is over Wifi, and some devices get the message later than others, which gives a very messy result. I don't want to get the latency of every device because this is a very unreliable approach. I want something as accurate as possible.
For example, in FPS games, it is common to have a countdown at the start of the round, and every player can start playing at the same time. What kind of logic lies behind this?
As for what my code currently looks like:
I use a BufferedReader in android to read every line sent by the server. The server is a console application in which you can type a message, and when you press enter, every listed client receives it with a new thread for every client.
java method receiving messages:
private void readMessage() throws IOException {
String data;
while ((data = mBufferedReader.readLine()) != null) {
data = data.toUpperCase();
if (data.startsWith("POSITION")) {
String[] splitData = data.split("/");
Log.d(Constants.TAG, splitData[1]);
mMainActivity.setDevicePosition(Integer.parseInt(splitData[1]));
} else {
String message = data.substring(data.indexOf('/') + 1, data.length());
int devices = Integer.parseInt(data.substring(0, data.indexOf('/')));
if (message.length() >= devices) {
message += " ";
} else {
int difference = devices - message.length();
for (int i = 0; i < difference; i++) {
message += " ";
}
}
mMainActivity.printMessage(message);
}
}
}
python line :
for cl in clients_list:
start_new_thread(send_message_thread, (cl, message,))

Read content of another app through my app

I have been searching the same problem for days. But unable to get any hint for that.
I need to create an app like voodoo app, which shows its custom layout only on specific pages of different apps like flipkart,etc.
Now, till this time, i have found options of using AccessebilityService and MediaProjection classes for the same. But i am stuck, how can i know programmatically, that Flipkart's Product Detail Page is visible so that i can display my app's custom view over it like Voodoo app does.
Any suggestions?
What you want to do is the following.
Using accessibility services track incoming events. Then you want to track TYPE_WINDOW_CONTENT_CHANGED events, and detect when the window content matches what you'd expect.
#Override
public void onAccessibilityEvent(AccessibilityEvent e) {
switch (e.getEventType()) {
case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: {
if (isFlipkartProdcutDetailPage(getRootInActiveWindow()) {
doStuff()
}
}
}
}
public boolean isFlipkartProductDetailPage(AccessibilityNodeInfo nodeInfo) {
//Use the node info tree to identify the proper content.
//For now we'll just log it to logcat.
Log.w("TAG", toStringHierarchy(nodeInfo, 0));
}
private String toStringHierarchy(AccessibilityNodeInfo info, int depth) {
if (info == null) return "";
String result = "|";
for (int i = 0; i < depth; i++) {
result += " ";
}
result += info.toString();
for (int i = 0; i < info.getChildCount(); i++) {
result += "\n" + toStringHierarchy(info.getChild(i), depth + 1);
}
return result;
}

Problems when sending a continuous stream of data over BLE

I'm wondering if anybody can help me figure out what is causing the data I am sending to become corrupt.
My setup is currently an Arduino pro mini with a HM-10 bluetooth module connected (I have also tried HM-11 Module too) and an Android application to receive the bluetooth data.
Module setup: http://letsmakerobots.com/node/38009
If I send data with big enough intervals then the data is fine, but if I send the data continuously I see messages getting mixed up and lost. To test this I send "$0.1,0.2,0.3,0.4,0.5" to the Android application from the Arduino, sometimes the stream of data appears to send fine but other times it is really quite scrambled. Please see the below graphs that demonstrate this:
Good case:
Bad case:
Arduino code:
String inputString = ""; //Hold the incoming data.
boolean stringComplete = false; //Determines if the string is complete.
boolean realtime = false;
void setup()
{
Serial.begin(9600);
delay(500);
Serial.print("AT+START");
delay(500);
}
void loop()
{
if(stringComplete)
{
if(inputString.equals("rStart"))
{
Serial.println("$startACK");
realtime = true;
}
else if(inputString.equals("stop"))
{
Serial.println("$stopACK");
realtime = false;
}
else{
Serial.print(inputString);
}
inputString = "";
stringComplete = false;
}
if(realtime)
{
Serial.println("$0.1,0.2,0.3,0.4,0.5,0.6");
delay(10);
}
}
void serialEvent() {
while (Serial.available())
{
// get the new byte:
char inChar = (char)Serial.read();
if (inChar == '\n')
{
stringComplete = true;
}
else
{
inputString += inChar;
}
}
}
The Android side just receives the data and then parses it in an IntentService:
#Override
protected void onHandleIntent(Intent intent) {
//Incoming command.
String rawData = intent.getStringExtra(DataProcessingIntentService.REQUEST);
//Append our new data to our data helper.
Log.i(this.getClass().getName(), "Previous Raw: (" + DataProcessingHelper.getInstance().getData() + ")");
DataProcessingHelper.getInstance().appendData(rawData);
Log.i(this.getClass().getName(), "New Raw: (" + DataProcessingHelper.getInstance().getData() + ")");
commandStartIndex = DataProcessingHelper.getInstance().getData().indexOf("$");
commandEndIndex = DataProcessingHelper.getInstance().getData().indexOf("\n");
//Set this as the data starting point.
if(commandStartIndex != -1){
DataProcessingHelper.getInstance().offsetData(commandStartIndex);
}
//Ensure that a command has been found and that the end index is after the starting index.
if(commandStartIndex != -1 && commandEndIndex > commandStartIndex){
//Remove the command structure from the command.
command = DataProcessingHelper.getInstance().getData().substring(commandStartIndex+1, commandEndIndex-1); //Remove the \r\n end command.
DataProcessingHelper.getInstance().offsetData(commandEndIndex+1);
if(command.length() > 1){
//Split the data out of the comand.
splitData = command.split(",");
Log.i(this.getClass().getName(), "Broadcasting the processed data. (" + command + ")");
//Broadcast data.
Intent broadcastIntent = new Intent();
broadcastIntent.setAction(DataProcessingIntentService.RESPONSE);
broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
broadcastIntent.putExtra(DataProcessingIntentService.RESPONSE, splitData);
sendBroadcast(broadcastIntent);
}else{
Log.e(this.getClass().getName(), "Command is less than 1 character long!");
}
}
}
Thank you for any help!
I have now figured out what was causing this problem. It appears that BLE only supports a maximum of 20 bytes per a transaction. The time between these transactions is different depending on what you are using. I'm currently using notifications which means that I can send 20 bytes every 7.5 milliseconds maximum. I have opted for 10 milliseconds to be safe. I will now need to look into breaking up packets into 20 bytes maximum to ensure no data corruption.

android DTmf tone

I am sending dtmf tone via this code.
String number="tel:+962791212121,2,3,3";
Intent c1= new Intent(android.content.Intent.ACTION_CALL, Uri.parse(number));
startActivity(c1);
It send perfect dtmf as this. 2+(2 sec delay)+3+(2 sec delay)+3.
but I want to remove that 2 sec delay or I want to control that delay.
How can I control (2 sec delay)?
Or any other method to send dtmf tone during call?
To remove the delay remove the comma.
Try this method().
private void call(int profileid) {//call procedure logic
ProfileDo profile = adapter.getProfile(profileid);
if (profile.getStepCount() == 0) {
Toast.makeText(getApplicationContext(), "Please edit the profile and add atleast one value to make a call", 10000).show();
return;}
String call = "tel:";
for (StepDO step : profile.getSteps()) {
String value = URLEncoder.encode(step.getValue());
int delay = step.getDelay();
String pausesStr = "";
for (int i = 0; i < delay / 2; i++) {
pausesStr += PhoneNumberUtils.PAUSE;
}
call += value + pausesStr;
}
startActivity(new Intent("android.intent.action.CALL", Uri.parse(call)));
}
Hope this helps you .
Try this:
Intent signalIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:12334566778"+","+","+"1"));
startActivity(signalIntent);

DTMF Tone Android [duplicate]

Is it possible to send DTMF tones in active call in android ? I tried it with proxyphone.sendDtmf() but it was useless.
How can i achieve it ?
In VOIP only it is possible,Android applications have no access to the in-call audio stream. You can fake a it a bit in speakerphone mode.
Try this method() .It is getting the number and delay from user.
private void call(int profileid) {//call procedure logic
ProfileDo profile = adapter.getProfile(profileid);
if (profile.getStepCount() == 0) {
Toast.makeText(getApplicationContext(), "Please edit the profile and add atleast one value to make a call", 10000).show();
return;}
String call = "tel:";
for (StepDO step : profile.getSteps()) {
String value = URLEncoder.encode(step.getValue());
int delay = step.getDelay();
String pausesStr = "";
for (int i = 0; i < delay / 2; i++) {
pausesStr += PhoneNumberUtils.PAUSE;
}
call += value + pausesStr;
}
startActivity(new Intent("android.intent.action.CALL", Uri.parse(call)));
}

Categories

Resources