How can I get mobile number automatically soon after user installs my android application. When registered in my application without entering manually. I am using the following code.
TelephonyManager manager =(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = manager.getLine1Number();
Make sure you have the permission READ_PHONE_STATE in manifest
also please look here for more information!
Related
Is there a way I can get IMEI(GSM)/MEID(CDMA) without implementing run time permission?
I have included the following permission in Android, however for some devices I get the IMEI number and for some Android devices I am getting my IMEI number and for some devices I get Exception {Java.Lang.SecurityException: getDeviceId at Java.Interop.JniEnvironment+InstanceMethods...
Why is that I have to handle the permission in the runtime despite listing them out in Manifest?
var telephonyManager = (TelephonyManager)Forms.Context.GetSystemService(Android.Content.Context.TelephonyService);
if (telephonyManager != null)
{
sIMEI = telephonyManager.DeviceId;
}
If there is no way other than giving permission at runtime and then getting IMEI, could someone suggest the best way to get Unique ID for the android device programmatically. (The device ID should be seen from device as well)
I tried the below but few post suggests that AndroidId is not the same everytime.
var android_id = Android.Provider.Settings.Secure.GetString(Forms.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
Answer is NO, If you're running on Marshmallow or above version then you need android.permission.READ_PHONE_STATE permission to access the device id.
Alternatively you can generate unique id using below code -
String uniqueID = UUID.randomUUID().toString();
OR you can follow below link for more options
deviceID
I'm making a pair of website-based apps for both Android and iOS interfaces, and I'm struggling with a part of it. Perhaps you guys could help me out!
I'm using Android Studio and Xcode, and launching the website through WebKit and WK WebView respectively. It's super simple, just an app which calls a website into it directly. No external navigation, nothing but a full-page website. And this part is working great!
But I do have one problem! I don't want my users to get consistently logged out if they close the app, or after a few hours of not using it. I'd like it to stay logged in for them, or to automatically log-in when they use it.
The maker of the website has given me a way to do this through the URL.
Basically, my URL currently is set up like "https://URL.com/x/y/z" and it goes to the website, and that is great, but I need to set it up to be "https://url.com/x/y/z/[insert user's IMEI or UDID here]". That unique ID from their Android device will keep them logged in. I've tested it using my own device with my own IMEI and it works great, but obviously using one specific identifier for everyone will not work. I just need it to call the specific user's IMEI or UDID into the URL, to complete it.
How should I go about this?
I am assuming that you are talking about an Android app that visualizes a website in an activity. On Android, you can retrieve the device's IMEI OR MEID string by calling:
android.telephony.TelephonyManager.getDeviceId().
But be warned, this requires that you add a permission to your manifest:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
You should inform your users why you are requesting this permission.
For iOS/Xcode, you can get the device UUID via UIDevice:
// Swift 4
let uuid = UIDevice.current.identifierForVendor!.uuidString
If you are targeting iOS 11 or newer, Apple introduced Device Check to get a device specific token. I personally haven't used it, but it sounds like it's use case is similar to what you're looking for.
Update:
From your comment, here is how'd you include it in the url string.
let urlString = "url.com/x/y/z/" + uuid
I have one small problem i.e whenever we install an application in our android mobile we need to find whether that application reads our contacts or not. If that application reads contacts then we have to raise one alert box with red mark and with some information. So thats why i am creating one application to find, the newly installed application reads our contacts or not.
Pls help me.
Thanks and regards.
Possible duplicate...
Answer is here: Java: Need some way to shorten this code
PackageManager p = context.getPackageManager();
final List<PackageInfo> appinstall =
p.getInstalledPackages(PackageManager.GET_PERMISSIONS |
PackageManager.GET_PROVIDERS)
If an application can read contacts it requires android.permission.READ_CONTACTS permission. If you want to specify some particular contacts that should raise an alert then you cannot do this on an application level. You need to get down to the Android Framework level and build your own version of Android.
i am developing the application in which user mobile no and international country code should be set automatically on the basis of SIM card provider.
i.e if i install this application in first page country code and my phone no should be filled automatically.i want this result as my output.
i have done this using static code but i want to do dynamically.if user uses this application then country code and mobile no should be selected automatically.
i have searched on net but there is not a exact answer of this question.
I have seen the application in which they are doing this thing so how they are doing?
Thanks
There is also one library which will helpful to you for validate user entered Phone number
as
http://code.google.com/p/libphonenumber/
Here is the code snippet that will help you in getting the phone number:
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = tMgr.getLine1Number();
Don't forget to include READ_PHONE_STATE permission in manifest file.
How do get the mobile number from an Android application? After installing the application on the mobile, I want to get the mobile number of the phone. Is there any API available in Android?
From my experience, this has been the simplest method:
TelephonyManager manager =(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = manager.getLine1Number();
And then add this to your AndroidManifest.xml
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
See http://developer.android.com/reference/android/telephony/TelephonyManager.html#getLine1Number%28%29: you will probably need the appropriate permissions to get it.