android Call Forwarding programmatically - android

I want to forward any calls received to another predefined phone number. I have searched forums and found some contradictory answers. so i m confused.
First I looked at this post https://stackoverflow.com/a/5735711 which suggests that it is not possible through android.
But another post has some solution. https://stackoverflow.com/a/8132536/1089856
I tried this code from second post, but i m getting the following error message: "Call Forwarding connection problem or Invalid MMI Code."
String callForwardString = "**21*5556#";
Intent intentCallForward = new Intent(Intent.ACTION_CALL);
Uri uri2 = Uri.fromParts("tel", callForwardString, "#");
intentCallForward.setData(uri2);
startActivity(intentCallForward);
Where 5556 is the number of emulator (for testing) where i want to forward call.

i think you need to try it on the device better than the emulator.
You are using DTMF codes, so i think you need network (on the actual device) rather than on the emulator.
Dial the same code "**21*5556#" on your emulator and check. It does not work either! Replace the 5556 with the phone number you want to forward the call to and then try it on phone.
Meaning, the DTMF codes would work only on mobiles not on emulators or tablets without SIM support.
EDIT:
you can find different call forwarding codes here.

Remove the "#" from Uri uri2 = Uri.fromParts("tel", callForwardString, "#");
if that do not work then try just *21*number#

Related

How to call from SIM 2 in Android?

I am building an android application where I want to call from SIM2 to particular number from my devices.
Below is the main code which I found from other links but that not useful for me.
Intent intent = new Intent(Intent.ACTION_CALL);
intent.putExtra("com.android.phone.extra.slot", 1); //For sim 2
intent.putExtra("simSlot", 1); //For sim 2
intent.setData(Uri.parse("tel:" + "**********"));
I am having OnePluse2 device. I checked other application like trueBalance and mubble that working fine. They are calling from SIM2 for checking it Balance.
But How I can also call from SIM2 and check there Balance!
can any one help me to solving this problem?
Your code works for samsung phones.Basically android does not provide an option to choose the sim to make a call, it is actually provided by the device manufacturers.There is not any official documentation available to achieve what you are trying to do.

Intent.ACTION_CALL - "Mobile network not available"

When I test my application with the emulator I get the following message: "Mobile network not available". Ofcourse I don't expect it to actually call from the emulator, but I want some sort of confirmation that it works.
In my application I use an intent like:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + Uri.encode(input.getText().toString())));
context.startActivity(intent);
I also implement this <uses-permission android:name="android.permission.CALL_PHONE"/> in the manifest-file.
Why is this?
EDIT: Seems like this only was a problem when I used GenyMotion. With the regular simulator, the call simulation worked.
You have to check and update if it works. This is my assumption which may work since I have not tried it by myself.
Open another emulator and note down its port number and use something like this
callIntent.setData(Uri.parse("tel:5554")); // assuming the second emulator port number is 5554
I am assuming this because, there is no sim card inserted in the emulator so you cannot call any real life phone number. But it is actually possible to dial one emulator from another using its port number using built in dialer app.

ANDROID Share information between my own app via intent

I'd like to share information between my own app running on 2 different phones via a bluetooth intent.
Lets say i have some data on phone a, then i will tap synch and it will start the same app at phone b (if it's not already open) with a bundle containing that "data".
My app on phone b acts acordingly.
Is that possible?
I am not really sure if this is what you're looking for.
Intent i = new Intent(Intent.ACTION_SEND); i.setType("image/jpeg");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse(fileLocation));
startActivity(Intent.createChooser(i, "Send Image"));
This intent shows all available options for file send such as Email and Bluetooth. Choose Bluetooth and the device initiates bluetooth discovery.
Thanks!
From my understanding, it is not possible.
Use BluetoothSocket and BluetoothServerSocket instead
I recently saw this interesting video about NFC, and i know you are talking about bluetooth.
but watch this video http://www.youtube.com/watch?feature=player_detailpage&v=49L7z3rxz4Q#t=768s
Timestamp added, starts at: 12:48.
What they did is starting the app trough nfc but probably they send the data trough bluetooth. Its really user-friendly.
In this way you do not need to push the button sync but just bump eachother phones together!
I hope this helps you maybe further,
Daniel
I think you must make use of BluetoothServerSocket to accept incoming connections. Exchange data with server once connected. To get started check out this doc.
Start-up
You could find the source code in your SDK. Download samples from Android SDK manager. Select 'Samples for SDK' from the required SDK version.
Go to
<location of android-sdk>/samples/<version>/
Open 'Bluetooth Chat' application. It has almost everything you need.
Thanks!
By the way, don't forget to accept the answer!

Sending an MMS programatically to Metro PCS MMSC (via Nokia Implementation)

This is my first post so my apologies in advance if this is the wrong site to post this particular question to.
Question
I have integrated Nokia's MMS implementation for android (http://androidbridge.blogspot.com/2011/03/how-to-send-mms-programmatically-in.html) into an android application I am writing and I am able to send MMS's from my personal Metro PCS device to Metro PCS's MMSC and messages are delivered to any recipient without issue.
This is how I am sending the MMS:
public Boolean sendMMSMessage(final String senderNumber, final String smsText, final File imageFile, final Integer requestId){
byte[] out;
Enumeration keys;
//set image File
setImageFile(imageFile);
//create MMMessage
setMMMessage(new MMMessage());
//add text
addText(getMMMessage(),smsText,"<0>",IMMConstants.CT_TEXT_PLAIN);
//add image file
addFromFile(getMMMessage(),getImageFile(),"<1>",IMMConstants.CT_IMAGE_JPEG);
//set MMEncoder
setMMEncoder(new MMEncoder());
getMMEncoder().setMessage(getMMMessage());
//transaction ID (second parameter) is arbitrary
setMessage(getMMMessage(),"T135d743a6b7",senderNumber);
try {
getMMEncoder().encodeMessage();
out = getMMEncoder().getMessage();
setMMSender(new MMSender());
getMMSender().setMMSCURL("http://mms.metropcs.net:3128/mmsc");
//'min' of sending device. Required by Metro PCS MMSC.
getMMSender().addHeader("X-DEVICE-MIN", min);
setMMResponse(getMMSender().send(out));
} catch (Exception e) {
System.out.println(e.getMessage());
return false;
}
return (getMMResponse().getResponseCode()==IMMConstants.HTTP_RESPONSE_OK);
}
I am wondering if it is possible to 'tweak' Nokia's code (if this is necessary) such that any device can send a properly constructed MMS request to Metro PCS's MMSC using my 'min' credentials. I have studied the packet flow (via 'WireShark') of what occurs when an MMS is successfully sent from my particular device to other recipients however when I run this same android app. on another device (a non-Metro PCS device), MMS messages fail to send and 'WireShark' is not helpful in explaining why. Can anyone help lead me in the direction of how I might make this work?
Update: It may help to add that logcat reports:
java.net.SocketTimeoutException: Connection timed out
Second Update: I took a look at another post regarding this issue. It is titled "Android sending image via MMS programatically(Operation timed out)" but unfortunately there currently is not a definite answer and this question has been live for two months. I will try increasing the read 'timeout' as someone suggested (I doubt this is the cause) but if anyone DOES know what the problem might be but simply wishes not to provide a direct answer this is fine. I just need a hint of where to look.
Third Update: Now that I think about it, I wonder if the senders IP address (the actual IP address used by the device) constitutes a factor here. Can anyone confirm?
Fourth Update: I just took a closer look at the code for 'MMSender.java' (specifically at whats going on with the 'HttpURLConnection' object) and according to its setReadTimeout(ms) method, the default value ('0') establishes an infinite wait time anyways and this method is not called anywhere in the code. Just for kicks, however, I manually set this value to 1 minute for both setConnectionTimeout(ms) and setReadTimeout(ms) and as I suspected, no dice. Same connect timeout issue.
Final Update: Sorry. I just realized that I copied this line of code from another posting some time ago:
((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE)).startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,"enableSUPL");
and now after looking at this call more closely, I wonder if it is possible that I am supplying incorrect parameter values to startUsingNetworkFeature() (at least for the non-Metro PCS device I am trying the application on). I don't want to overkill my 'updates' here for this question but I want you guys (or gals) to be well informed so...; if these parameter values do turn out to be the problem, I will definitely post that fact but this will be my final update. In the mean time, any advice is greatly appreciated.

Intent to send an SMS to multiple contactcs

Trying to initiate an intent to send an SMS to multiple recipients with the following code:
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"sms", destination, null));
However in the destination string say I have "555-555-5555,555-555-5556". The comma delimiter is working fine on a Samsung vibrant. However, this will not work on a nexus 1. On the nexus one i need to use a semicolon as the delimiter and then it works. On the nexus one, if I use commas as the delimiter, it only picks up the last phone number. If I use the semicolon, the nexus one picks up all the phone numbers however, it then breaks the vibrant. With the semicolon, the vibrant does not pick up any of the phone numbers. Any insights?
You should file feature request in android
for the public telephony api to standardize this kind of stuff.
Until now (Gingerbread 2.3.3) there is no "default character" or api do discover what is the correct for each rom.
Anyway, I suggest that you ask people do test in different roms and create switch cases in your app. It will not work in all of them, but could work in most of.
Semicolon works for other than samsung and Comma works for Samsung devices. Just put a check for:
String manufactures = android.os.Build.MANUFACTURER;
to achieve the same functionality for both samsung vs others.

Categories

Resources