Retrieve Details Such as MCC,MNC,LAC,CellID - java

Is it possible to get the following information of a incoming number in android
MCC
MNC
LAC
Cell ID
I have tried the code
TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = tel.getNetworkOperator();
if (networkOperator != null) {
mcc = Integer.parseInt(networkOperator.substring(0, 3));
mnc = Integer.parseInt(networkOperator.substring(3));
}
It returns the details of the current SIM, But I want to find it for the incoming number

This is tricky for this you need to implment a application in that user's phone also. Because when you are getting the call from some user then you will get only MSISDN through which you can not gwt the details. There should be a app on other users mobile which will trigger a event in case he makes a call, now that app can fetch the MCC.MNC and cell id and can send via sms to called party and then called party can process this sms to get the details. Its simple logic that if you want to spy someone then you have install something at his end.

This would give you the # :
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String sim = telephonyManager.getSimSerialNumber();
Also add this permission to the manifest :
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
for getting the mobile # change it to :
String sim = telephonyManager.getLine1Number();
You could also refer to this : Access the SIM Card with an Android Application?
For getting incoming caller sim details refer to this : http://sms411.net/2006/07/finding-out-someones-carrier/
and
How do i get the carrier name of an incoming number in android..?

The solution :
You can't because the data of incomming call contains only the number as string, and by sms ? also no
because the user data header of the message can be null !!!
If you develop a current location application, it can be used only by the owner of the cell phone.
In the other hand, there are some developer who want to use the AT command to request the call but the only data comes with a call is only the number and only the number !!!

Related

How to avoid duplicate IMEI NO of phone in Android Application?

I wanna avoid same request of multiple user from same device in my android application. For that case, I wanna avoid duplicate IMEI NO of phone that how one user can't request an event from multiple user ID using same device.
How can i do this?
How can drop a pin on specific location?
If one user registered on my application, then drop a pin on google map that can I specify the user's in future to search as another users nearby. How can I do this on android application development?
Reference - https://medium.com/#ssaurel/how-to-retrieve-an-unique-id-to-identify-android-devices-6f99fd5369eb
import android.telephony.TelephonyManager;
import android.content.Context;
TelephonyManager telephonyManager;
telephonyManager = (TelephonyManager) getSystemService(Context.
TELEPHONY_SERVICE);
/*
* getDeviceId() returns the unique device ID.
* For example,the IMEI for GSM and the MEID or ESN for CDMA phones.
*/
String deviceId = telephonyManager.getDeviceId();
You will need to request for permission - android.permission.READ_PHONE_STATE
Also, verify if this requires runtime permission on M and above!

TelephonyManager unable to return phone number in android

I'm implementing a payment app. So for contact verification I have to find the contact number. Also i'm sending a sms from sim for cross verification on server. I have tried
> TelephonyManager tm =
> (TelephonyManager)this.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
> String phoneNumber= tm.getLine1Number();
but I'm unable to get contact number. I have also implemented broadcast receiver to check weather sms sent or delivered. So is there any way to get the contact number or not?
Have you defined this permission in manifest:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Also use getActivity().getApplicationContext(); in place of this.getApplicationContext() if you are using fragment

Send Parse Push notification with specific user

I'm programming an Android App about share different content. Now I develop the social network, and when one user add new friend, send a Parse Push notification that the user add you.
I use Parse SDK, and I don't now how to do this.
I try this:
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("userId",id);
try {
installation.save();
This create a userId column in Installation class of Parse Data. (I see Parse Data and the userId column is the correct id from user)
Next I do:
//Create our Installation query
ParseQuery<ParseInstallation> pushQuery = ParseInstallation.getQuery();
pushQuery.whereEqualTo("userId",ParseUser.getCurrentUser().getObjectId());
// Send push notification to query
ParsePush push = new ParsePush();
push.setQuery(pushQuery); // Set our Installation query
push.setMessage("Willie Hayes injured by own pop fly.");
push.sendInBackground();
I create a query that compare the userId colum (that contains the userId from user that add you) with the current ParseUser, but the Push don't send, and nobody receive.
Please help me.
Thanks.
What I did is I registered the device to a channel corresponding with the user. In Swift I did it like this, but in Android it would be very similar. This means that user "userId" would be subscribed to channel "user_userId".
let currentInstallation = PFInstallation.currentInstallation()
currentInstallation.channels = ["user_" + PFUser.currentUser().objectId]
currentInstallation.saveInBackground()
Then when you want to send the push, send it to channel "user_userId".

Send post notification to specific UUID android device

I'm trying to find some ways to send a post notification to specific android device using its UUID , so I will do the following :
1 : login screen on android and then get UUID number from the device
2 : send this UUID to online database linked to userID
3 : I want to know how to send post notification to a specific UUID which I get from my database ?
Sending notification to android device using java is very easy.
If you want to push the notification directly from REST client, then you can refer this
If you want to send notifications from your java program, then follow these simple steps,
Add gcm-server.jar library file in your application
Create a Sender, that will send the notification
com.google.android.gcm.server.Sender sender = new Sender("pass your gcm api key here");
Then create a message object that will contain the data that you want to send
com.google.android.gcm.server.Message message = new Message.Builder().addData("key","value").build();
addData("key","value") in above code will add the key value in json to be send.
Then you can choose any of send method provided in Sender class
com.google.android.gcm.server.Result result = sender.send(message, device_token, no of retries);
There are total four version of send method available. You can find more detail about Sender class here

android device id confusion

If I dial
*
#
*
#
8
2
5
5
#
*
#
*
, I get my android device id which starts with android-35c2acdd...
source
If I use Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID) the result starts with a96b4b27...
If I use ((TelephonyManager) Context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId() the result starts with 3538330...
What is the difference between these ID-s? How can I get the result of the
*
#
*
#
8
2
5
5
#
*
#
*
dial?
IMEI
The IMEI is the 'MAC' for the telephony module - the unique ID that the telephone uses when it connects via GSM/GPRS/HSPDA/etc. The GSM network uses it to route calls and data from the phone over the GSM network right up to the gateway into the Internet (which is an IP network).
A telephony module is a chip or circuit board that handles the telephone network, either GSM or CMDA, and often has a slot for a removable SIM card. Some phones have more than one telephony module (active dual- or multi-SIM phones). Each telephony module has its own IMEI.
Manufacturers give each phone (strictly the telephony module) a unique IMEI during manufacturing. However the number can normally be rewritten if you have the right software. This is often done after a phone has been stolen to give the phone a new identity and bipass stolen phone blocking system.
The IMEI can be programmatically obtained using the TelephonyManager.getDeviceId() API.
CDMA phones have a ESN or MEID which are different lengths and formats, even though it is retrieved using the same API.
Android devices without telephony modules - for example many tablets and TV devices - do not have an IMEI. As Schlangi commented, some devices that do not have a telephony module fake the IMEI, so the presence of an IMEI does not (always) guarantee the device has a telephony module.
ANDROID_ID
The ANDROID_ID is another unique number on the phone - this is automatically generated by the OS as it boots for the first time (doing it this way makes it much easier for the manufacturers by removing a step from the production line).
The ANDROID_ID can (and does) change, for example:
Factory reset (including when reflashing the OS)
In software: eg https://play.google.com/store/apps/details?id=com.vcastroi.changeid
It is mainly used by developers (eg identifying and connecting to devices using adb)
ANDROID_ID can be used to identify an Android device given the caveats above, realistically meaning that it uniquely identifies the device over significant portions of the device lifetime, but cannot be relied on.
Also note that there was a bug in Froyo where many devices gave themselves the same ANDROID_ID. This is the bug
Other identifiers
There are a number of other things that can be used identify the device:
MAC address of the WiFi module: WifiManager.getConnectionInfo() -> WifiInfo.getMacAddress(). This can often be changed in software, but generally is constant over the device lifetime. Also it can only be read if the WiFi module is switched on.
MAC address of the BlueTooth module: BluetoothAdaptor.getAddress(). Like WiFi MAC, this can often be changed in software and may be off when you need it
The subscriber's telephone number. This may change if the user requests a new number from the telco, or if the user switches SIMs. It is obtained from TelephonyManager.getLine1Number(). This is only present for Android phone devices with a current SIM installed and a paid service with a telco.
The SIM contains its own identifying number (IMSI). This is obtained from the TelephonyManager.getSubscriberId() API. Obviously the SIM may not be present at any specific time, and it changes when the SIM is changed - and users can upgrade/replace their SIM while keeping the same number, so you can't say that this is one-to-one to a specific phone or user.
Related to the IMSI is the MSISDN. This functions as the identification of a subscription (your contract for a specific telephone number with your mobile provider) and therefore gives the device its telephone number. The MSISDN may be associated with several SIM cards, and therefore several phones. It comes with all the caveats for reading the SIM above. This may be retrieved with TelephonyManager.getSimSerialNumber(). Thanks Schlangi for the corrections and additions
Gingerbread and later has android.os.Build.SERIAL which many manufacturers set (but not all. Bugger).
Other notes
You need specific permissions to access each and every API, so if you try for all of them, your app's permissions in the Google Play store look fairly permissive.
I think this link explains all the other available options also https://android-developers.googleblog.com/2011/03/identifying-app-installations.html
Found on the web:
private static final Uri URI = Uri.parse("content://com.google.android.gsf.gservices");
private static final String ID_KEY = "android_id";
String getAndroidId(Context ctx) {
String[] params = { ID_KEY };
Cursor c = ctx.getContentResolver()
.query(URI, null, null, params, null);
if (!c.moveToFirst() || c.getColumnCount() < 2)
return null;
try {
return Long.toHexString(Long.parseLong(c.getString(1)));
} catch (NumberFormatException e) {
return null;
}
}
Add permission:
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
However, I doubt that is a documented ID and I would be carefull because that might not work if GTalk gets updated.
Source: http://blog.codepainters.com/2012/01/17/how-to-obtain-gtalk-android-id/
Also worth having a look at: http://www.toxicbakery.com/android-development/getting-google-auth-sub-tokens-in-your-android-applications/
There are some approach to get unique identifier on android phone.
Android ID
It is a 64-bit hex string which is generated on the device's first boot.
Generally it won't changed unless is factory reset.
Secure.getString(getContentResolver(), Secure.ANDROID_ID);
The Android ID , considered unreliable because it can sometimes be null.
The documentation states that it "can change upon factory reset".
This string can also be altered on a rooted phone.
String m_szAndroidID = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
Returns: 9774d56d682e549c . No special permissions required.
2. The WLAN MAC Address string, is another unique identifier that you can use as a device id.
Before you read it, you will need to make sure that your project has the android.permission.ACCESS_WIFI_STATE
permission or the WLAN MAC Address will come up as null.
WifiManager wm = (WifiManager)getSystemService(Context.WIFI_SERVICE);
String m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
Returns: 00:11:22:33:44:55 (not a real address since this is a custom ROM , as you can see the MAC address can easily be faked).
WLAN doesn't have to be on, to read this value.
3. The BT MAC Address string, available on Android devices with Bluetooth, can be read if your project has the android.permission.BLUETOOTH permission.
BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter
m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String m_szBTMAC = m_BluetoothAdapter.getAddress();
Returns: 43:25:78:50:93:38 . BT doesn't have to be on, to read it.
4. IMEI only for Android devices with Phone use:
TelephonyManager TelephonyMgr = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String szImei = TelephonyMgr.getDeviceId(); // Requires READ_PHONE_STATE
This requires adding a permission in AndroidManifest.xml, and users will be notified upon installing
your software: android.permission.READ_PHONE_STATE. The IMEI is unique for your phone
and it looks like this: 359881030314356 (unless you have a pre-production device with an invalid IMEI like 0000000000000).
For more info refer this link.
IMEI
There is a mandatory requirement by the standardization bodies, that mobile devices for public networks may be uniquely identified by the IMEI number
It is the manufacturer's responsibility to set IMEI. In practice, developers sometimes see IMEIs like 000000... or 123456... Sometimes phones with identical IMEI go to production, which of course is a bug that should be fixed...
ANDROID_ID
A 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain constant for the lifetime of the device. (The value may change if a factory reset is performed on the device.)
It looks like Android does not trust the manufacturers and provides an alternative unique ID.
EDIT:
This is what I get (instead of IMEI) on and Android device that is not a phone:
$ adb shell dumpsys iphonesubinfo
Phone Subscriber Info:
Phone Type = GSM
Device ID = null
I think all the information provided above is well enough to understand the codes.
Yet I think you are still "not able to see the result of the ##8255## dial" (plz excuse if I went wrong somewhere in understanding this)
I assume the reason behind this is one of the latest bug fix against USSD code made in Android.
(you may read more about this and check if your device is on the list. its all over the web)
Finally, if you just want to get the android ID straightaway i suggest you to use this app-
https://play.google.com/store/apps/details?id=com.redphx.deviceid&hl=en

Categories