Not getting the number In Dual Sim Android Phone Programatically - android

I need to get number of Sim one while having dual sim android phone and not getting this by following code.
I am getting everything exact the same as it is but not getting the sim number
In My manifest file
uses-permission android:name="android.permission.READ_PHONE_STATE"
My main activity
TelephonyManager tel = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
TextView txt=(TextView)findViewById(R.id.textView1);
txt.setText("Operator Code : " + tel.getSimOperator().toString()
+ "\nOperator Name : " + tel.getSimOperatorName().toString()
+ "\nCountry ISO : " + tel.getSimCountryIso().toString()+"sim"+tel.getLine1Number()+" Serial Number : " + tel.getSimSerialNumber().toString()
+ "\nMobile Number : " + tel.getLine1Number().toString());
Please help with the example code

I just figured it out today....... and that's help me in clearing many things
What does getLine1Number() return with dual SIM phones?

Related

How to run USSD code in android

i am using dual sim phone. Now i want to run USSD code by one particular network without selecting the operator to call.
my code:
String ussdCode = "*" + "123" + Uri.encode("#");
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + ussdCode)));
Response: now it was asking me to select the operator to call the ussd code. I want to run that USSD Code by that particular operator without asking.
Thank you in advance.
With Samsung devices use the below
callIntent.putExtra("simSlot", simSlot);
where simSlot is integer as 0,1

How to obtain Firmware version of Android programmatically?

The following screenshot of a generic tablet shows an example of Firmware version:
We have tried pretty much everything of Android Build, none of them is the firmware version.
Firmware is the operating software available on an Android device, and it is available in different versions designed by different manufacturers. Basically it's the device-specific part of the software. For example, you may have Android 4.2.2 running on your phone, but have a firmware number that looks completely different because it relates to more details than just Operating System. The firmware number consists of several elements, all of which are essential for the functioning of the phone:
PDA: Android operating system and your customizations.
Phone: the actual identifier of your device.
CSC (Country Exit Code): the languages and country-specific parameters.
Bootloader: the boot loader program that runs at startup to all unit processes.
Software Build Version is basically the Firmware Version.
See android.os.Build.VERSION. SDK or SDK in contain the API version. android.os.Build.VERSION_CODES contains the relevant constants.
String deviceSoftwareVersion=telephonyManager.getDeviceSoftwareVersion();
Refer to this Build.VERSION
Procedure to use it in code.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
// only for gingerbread and newer versions
}
This can be also checked by through code
System.out.println("button press on device name = "+android.os.Build.MODEL +" brand = "+android.os.Build.BRAND +" OS version = "+android.os.Build.VERSION.RELEASE + " SDK version = " +android.os.Build.VERSION.SDK_INT);
UPDATE
Try this one -
android.os.Build.FINGERPRINT
android.os.Build.BOARD
Build.HOST
Build.ID
Build.SERIAL
Check the following Code.
FINAL UPDATE
String mString = "";
mString.concat("VERSION.RELEASE {" + Build.VERSION.RELEASE + "}");
mString.concat("\nVERSION.INCREMENTAL {" + Build.VERSION.INCREMENTAL + "}");
mString.concat("\nVERSION.SDK {" + Build.VERSION.SDK + "}");
mString.concat("\nBOARD {" + Build.BOARD + "}");
mString.concat("\nBRAND {" + Build.BRAND + "}");
mString.concat("\nDEVICE {" + Build.DEVICE + "}");
mString.concat("\nFINGERPRINT {" + Build.FINGERPRINT + "}");
mString.concat("\nHOST {" + Build.HOST + "}");
mString.concat("\nID {" + Build.ID + "}");
((TextView) findViewById(R.id.textView1)).setText(mString);
You can also useBuild.DISPLAY
A build ID string meant for displaying to the user
I used following code to get firmware version of my device:
public String getFirmwareVersion() {
try {
Class cls = Class.forName("android.os.SystemProperties");
Method method = cls.getMethod("get", String.class);
method.setAccessible(true);
return (String) method.invoke(cls, FIRMWARE_VERSION_PROPERTY);
} catch (Exception e) {
return null;
}
}
As FIRMWARE_VERSION_PROPERTY I used "ro.product.version"
I've got this property address from the device manufacturer.
This address can vary for different devices and manufacturers, so it's advisable to contact manufacturer's tech support to get the correct one.

How to get the device Model Name? [duplicate]

This question already has answers here:
Get Android Phone Model programmatically , How to get Device name and model programmatically in android?
(16 answers)
Closed 6 years ago.
How to get the device model name ? I have a Yuphoria 5010 which displays YU5010 in device Model Number, I want to fetch the full name of the device? I want the fetch the exact string given below:
Yuphoria 5010 6.0 Marshmallow
It was really simple, just call:
String model = Build.MODEL;
Update: This code will print the exact string you requested:
String reqString = Build.MANUFACTURER
+ " " + Build.MODEL + " " + Build.VERSION.RELEASE
+ " " + Build.VERSION_CODES.class.getFields()[android.os.Build.VERSION.SDK_INT].getName();
Prints:
Samsung Note 4 6.0 MARSHMALLOW
LGE LG-D410 4.4.2 KITKAT
On many popular devices the market name of the device is not available. For example, on the Samsung Galaxy S6 the value of Build.MODEL could be "SM-G920F", "SM-G920I", or "SM-G920W8".
So for getting full device name you can use a library which is available on github . Link of AndroidDeviceLibrary is here https://github.com/shubhamsharmacs/AndroidDeviceNames
Now how to use these library :-
put these in your build.gradle file
compile 'com.jaredrummler:android-device-names:1.0.9'
Now these operations are :
Get the name of the current device:
String deviceName = DeviceName.getDeviceName();
The above code will get the correct device name for the top 600 Android devices. If the device is unrecognized, then Build.MODEL is returned. This can be executed from the UI thread.
Get the name of a device using the device's codename:
// Retruns "Moto X Style"
DeviceName.getDeviceName("clark", "Unknown device");
Get information about the device:
DeviceName.with(context).request(new DeviceName.Callback() {
#Override public void onFinished(DeviceName.DeviceInfo info, Exception error) {
String manufacturer = info.manufacturer; // "Samsung"
String name = info.marketName; // "Galaxy S7 Edge"
String model = info.model; // "SAMSUNG-SM-G935A"
String codename = info.codename; // "hero2lte"
String deviceName = info.getName(); // "Galaxy S7 Edge"
// FYI: We are on the UI thread.
}
});
The above code loads JSON from a generated list of device names based on Google's maintained list. It will be up-to-date with Google's supported device list so that you will get the correct name for new or unknown devices. This supports over 10,000 devices.
This will only make a network call once. The value is saved to SharedPreferences for future calls.
You can get the device details by using the below code.
String s="Debug-infos:\n";
s += "OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")\n";
s += "OS API Level: " + android.os.Build.VERSION.RELEASE + "(" + android.os.Build.VERSION.SDK_INT + ")\n";
s += "Device: " + android.os.Build.DEVICE + "\n";
s += "Model (and Product): " + android.os.Build.MODEL + " ("+ android.os.Build.PRODUCT + ")\n";
USe this code for get device Model
import android.os.Build;
String deviceModel = Build.MODEL;
if you want get this info in android 6.0 Marshmellow so before this get info give the run time permission
Manifest.permission.READ_PHONE_STATE

ampersand in text message - sms sending android

So here's my problem.
I have a Timer which is supposed to send a SMS every X seconds.
And i want the text message to be the current GPS location of the user.
So, i want to send a kind of Google Maps URL, using the GPS coordinates i get, and adding some markers, maptype, size.... for the map.
To do that, i need to use the character "&" in the URL. In order to get something like that :
http://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&maptype=roadmap
(ie : https://developers.google.com/maps/documentation/staticmaps/?csw=1#URL_Parameters)
But, when i want to use this kind of URL, using "&" in my text message of the SMS. The SMS is never sent. When i remove every part containing the "&", it's working fine.
I tried to use "&amp ;" instead of "&". Still doesn't work.
Here's my SMS manager to send the SMS :
smsManager.sendTextMessage(INT, null, "Alert - RED AREA \n TIME : " + current date + " \n Lat: " + latitude + " \n Long: " + longitude + "Link Maps : http://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude +"&zoom=12&size=400x400&maptype=satellite", null, null);
The code above, doesn't send any messages.
But this one does :
smsManager.sendTextMessage(INT, null, "Alert - RED AREA \n TIME : " + current date + " \n Lat: " + latitude + " \n Long: " + longitude + "Link Maps : http://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude, null, null);
Any ideas ?
Thanks !
Use "%26" instead of "&" or "&amp", the URL will still parse and the SMS will construct properly
The simplest solution would be to think of some sort of special character (or string) that you would use to replace the '&' character in your string.
You would go through your source string and replace every occurence of '&' with the special string (representing '&').
The reversed mechanism should be implemented in the receving side.
BUT BE CAREFUL! you need to choose your special string carefully! Because if you choose a string that could normally occur in your source string, the receiver would insert a fake '&' characters.
If this solution is not good enough, let me know... I have had a similar problem in one of my apps, and found a workaround without replacing a character with something else.

phone gap adding contacts problem

iam just practicing with phone gap for android app. I found a piece of code in docs.phonegap.com, regarding adding contacts
function onDeviceReady()
{
alert('onDeviceReady: PhoneGap1');
var myContact = navigator.contacts.create({"displayName": "Test User"});
alert('onDeviceReady: PhoneGap2');
myContact.gender = "male";
console.log("The contact, " + myContact.displayName + ", is of the " + myContact.gender + " gender");
}
When i run this i am getting only the alert box and the name is not added in my contacts. How to add the contacts....
Please tell me how to add data and open the device default contacts...
Simon Mac Donald has written a great blog post on contacts with PhoneGap and Android.
http://simonmacdonald.blogspot.com/2011/09/saving-contacts-with-phonegap-android.html
It should help you out as there are a few steps to it.
The quick answer for those of you searching, is that you have to call
myContact.save()
in order to persist the contact that you just created.

Categories

Resources