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.
Related
By this code:
Intent i = new Intent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setAction(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
context.startActivity(i);
I am able to open the data roaming setting activity successfully. Lets have a look at the screenshot:
When I click on the Data Connection it prompt me like this way:
because my phone is dual sim. Now I want to open the prompt window without clicking the data connection. Is it possible? Can I open the window(Second picture) directly?
Dual SIM support is part of AOSP since Android 5.1 (SKD22), so all previous versions feature vendors' extension, which means it is not standarized.
See: https://developer.android.com/about/versions/android-5.1.html
I am using Moto e for getting my sim number by telephoney methode telephonyManager.getLine1Number() . but it retrieves blank .
can anybody have any idea about other ways to find sim number/numbers?
the getLine1Number() return phone number if we have number listed in About Phone section in Settings. Otherwise we can't and I also didn't find any other options till now .
I believe the Moto E is a dual sim phone. Android didn't support that before 5.1 I believe, so that call won't work (even if you have simcards in both slots).
To get the number of a dual sim phone, please follow this method:
https://stackoverflow.com/a/17499889/1642200
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.
I wanted to disable features related to CALL and SMS in my application based on whether SIM hardware is present or not. Now a beginners approach towards this will be checking the Phone type using :
if (telephonyManager1.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE)
If true then its supported.
Everything was fine until i came across Sony Tablet S which has a SIM support only for Data and Messaging. No voice support. So for this device i need to disable only CALL feature but continue with SMS support.
Sony tablet returns TelephonyManager.PHONE_TYPE_NONE so i can`t use the above methods.
Also ,
telephonyManager1.getSimState();
returns 1 i.e SIM_STATE_ABSENT which is also same in case of HTC FLYER which has no support for SIM hardware itself.
So is there any way in which i can come to know if SIM hardware is there(irrespective of SIM card inserted or not) ?
Use
PackageManager pm = this.getPackageManager();
boolean hasTelephony=pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
Edit:
Try using
TelephonyManager.getLine1Number()
If this returns null then you wont have telephony feature. Have not tried. give it a shot
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#