I am developing one Android app for that I need to stop and start mobile data.
The problem is that how can I determine whether the mobile is dual SIM or not?
Also if it is dual SIM then how can I do my operation on second SIM?
Thanks !
Safely and decently, you can't.
If you're ready to limit your app to certain devices and give up on it being future proof, you can determine whether the mobile phone is dual SIM by trying to do something that only a specific dual SIM phone can do. If it works, it's surely dual SIM. If it doesn't, well... You won't know. Maybe it's a chipset you didn't cover.
I'll give you an example. If you wish to cover Mediatek chipsets, try this:
long gprsConnectionSimSetting =
Settings.System.getLong(context.getContentResolver(),
"gprs_connection_sim_setting");
It is a Mediatek powered dual SIM phone, if gprsConnectionSimSetting holds one of these values: 0, 1 or 2.
Value 0 stands for "mobile data disabled on both SIMs", value 1 means "mobile data goes through SIM1" and, you've guessed it, value 2 tells us that SIM2 is being used for mobile data.
Related
Is it possible to dial two numbers in same time ?
Maybe android.telecom.Conference
can help me , but there is no lot of examples for this class usage.
android.telecom.Conference
Doc say :
Represents a conference call which can contain any number of
Connection objects.
Than can be sim based connections .
I have no need for video call , i need just ringing /answer or reject .
Maybe dual sim devices ?
More :
https://www.youtube.com/watch?v=XcVBZkA2kI8
(https://developer.android.com/reference/android/telecom/Conference.html)
Yes it is possible you can use views as visible/invisible/gone when you are entering it
I am trying integrate a GPRS modem in Android 6.0.1 without success. Modem works well at hardware level and answer correctly AT commands. In Android UI I only see SIM card not present and nothing related to modem works.
In Android log I can see a lot of subId=-2, phoneId=-1, slotId=-1, I think my problem is because of this wrong numbers.
Someone with experience in Android RIL could help me to understand how this numbers are generate and where?
I think my reference-ril.c is OK, and I can't understand why this Id are not generate correctly.
In almost all the case PhoneId equals slotId, it means which SIM card slot the current subscription is on.
SubId maintain a record for SIM cards that have been inserted. eg, You insert a card with Iccid 46332223***3232 and the telephony record it as a subId=1, for another card with Iccid 46332223***9900, telephony record it as SubId=2.....Next when you insert 46332223***3232 again, telephony will know it's an acquaintance card, and SubId will again set as subId=1. So it's for other cards.
If SIM card is not presented, pls first check the GET_SIM_STATUS in your log, if the state is absent, you should check the modem part.
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 get phone number of android device. I use this code:
TelephonyManager tm = (TelephonyManager)this.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber= tm.getLine1Number();
On my phone (HTC Wildfire) I can not get phone number - all I get is empty string. If I run code on emulatur, phone number is normally showed.
If I go to Settings=>About phone=>Phone identity->Phone number, phone number is "Unknown".
Where is the problem? Is something wrong with my SIM?
We had the same problem in our project. The conclusion was that it depends on the SIM card.
What happened to us:
Galaxy S with AT&T SIM card: can read phone number, Settings shows number
Same Galaxy with an European SIM card: cannot read the number and "unknown" in Settings (cell phone was perfectly functional, just couldn't read the number)
This has been reported in other forums as well.
In the end we decided to ask the user for the phone number. A bit more involved, actually: if( "SIM card present" && "cannot read the cell number") "ask user"; . Otherwise we will keep bugging the user that doesn't a SIM card in the first place.
Instead of the phone number use the SIM card serial number, which always exists and is always a valid value.
telephonyManager.getSimSerialNumber();
SIM serial number is unique within the operator at least. So combined with
telephonyManager.getNetworkOperator();
you'll have a unique identifier for a subscriber within a country.
This combined with
telephonyManager.getNetworkCountryIso();
you'll have a globally unique identifier for a subscriber.
Hope this will help.
Cheers.
SIM card stores phone number and it can be edited by you. Cant say for Android, but on WM you can easily edit your phone number, which is stored on SIM card.
Of course, it does not mean that you can change your phone number on the fly. Actually, you are free to write there any number you like, and the programs will believe, that this is your real number :)
When I've moved a SIM card into a new phone, I've sometimes found that the phone number does not show up in Settings -> About phone -> Status -> My phone number.
My data points:
AT&T Atrix putting completely new SIM in it says “Voice MSISDN Line1 null”.
T-Mobile G1 putting new SIM card into it correctly displays the phone number.
T-Mobile G2 moving SIM card from my old G1 into is says "Unknown".
Telephone number available if the SIM card is allows it get his.
In our company I found only one SIM, which is allowed get number. I'm tetsting this SIM on all android device. All ok. getLine1Number() is ok.
Now I'm looking for get phone number for other SIM. Have send sms to our sms-server or other android device(with the processing of SMS)
I use a simcard which only permits data transfer. It doesn't permit phone calls.
When I try to get phonenumber with getLine1Number(), I get empty string.
I want to get the mobile number of a sim which is inserted into the device. I know as pr the android SDK TelephoneManger is the class by which we can get it by getLine1Number() method. but it always returns null values.
Queries:
Can i get mobile number from
device?
Is it a sim dependent or in some case
also device dependent?
Any other ways to get the mobile number from device?
You are using correct and the only approach available to the common user (AFAIK). It is mainly SIM dependent (it is not obligatory to have ), and in some cases may be device dependent (getLine1Number() not correctly implemented).
To be more precise, IMSI uniquely identifies SIM. But MSISDN (the subscriber number) is not uniquely related to SIM, as it is possible to change MSISDN on the SIM. Network may use IMSI from SIM to find MSISDN in the HLR and establish the call.
So, MSISDN is not mandatory to be on the SIM.
You should look at this question and its comments.
Some SIM cards seems to cause getLine1Number() to return null... and no one has found a way to deal with this.
More information here
In that case you always save your phone no using SharedPreference by using the method getLine1Number() method. when you install your application then your phone number is saven and when when new sim card is used then send SMS to ur registered number. you have to always check after starting the application that your stored number is same with your new number.if same nothing will be happned ,if not same then ur app will send SMS.