How to read the device name from phone setting in android, As shown in below image how to read the first field that is "device name" in android.
In some phones, the device name is the same as the model name but in some phones both are different so how to particular read device name from phone settings in android?
Any help is appreciated!
here you go
Settings.Global.getString(getContentResolver(), Settings.Global.DEVICE_NAME)
You can directly use this, Use in your logcat to see the result.
Build.DEVICE
Related
If I am charging my Huawei Phone and go to Settings --> Battery there is at the Top a Value, that shows how mach time my Phone needs until it is fully charged. My Question now is, if there is a way to extract this value with Flutter and use it in my App?The Battery value
Try to use battery_level package for get information about a device battery state.
Yes you can get the battery level from a huawei phone. Use this package: https://pub.dev/packages/battery. It will help grab the battery level information and allow you to use and manipulate it in flutter.
I tested this on honor v30 and it works fine.
i want to know does the android advertising id change when the android device is reset.
In my project am handling condition with aid, when the device is rebooted it doesnt working.
The answer is NO. AdvertisingId value is related to your Google acount, not specific phone.
Check: http://www.tomsguide.com/faq/id-2316491/reset-google-advertising-android.html
Cheers!
I have been searching for code through which I can fetch Device's name defined by user for his own device .
Have gone through various stackoverflow questions , but none seems to work for me ?
Image as seen in below : Will require Thanks Thanks (SM-T211 ) from android code
Try this:
String ownerInfo = Settings.Secure.getString(getContentResolver(),
"lock_screen_owner_info");
As of Android 4.4.2 the owner info value is moved to lock screen database,/data/system/locksettings.db to which 3rd-party apps have no read/write access. That's, there is no reliable way of reading owner info for later Android versions except for rooted device.
You need to get build.prop file of system which is possible either if your device is rooted or if your has system privileges....
heres the code you may follow to get and edit build.prop
Check this App in Play Store. build.prop Editor. Since it's open source, and the code is extremely simple, you can use it as a stating point: https://github.com/nathanpc/Build.prop-Editor
Try this :
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
String deviceName = myDevice.getName();
Make sure you add to your manifest:
<uses-permission android:name="android.permission.BLUETOOTH"/>
I am making an application and I want to retrieve the device phone number and send that on the server. But I am testing this application on android emulator. Can anybody please tell me how to set or get the phone number in emulator and actual device.
Thanks.
We can get the phone number in emulator if we use the Telephony manager
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String phone = tm.getLine1Number();
Toast toast = Toast.makeText(getApplicationContext(), phone, Toast.LENGTH_SHORT);
toast.show();
On making the toast of the phone number we get the phone number like..
15555215554
It also need the android.permission.READ_PHONE_STATE permission.
So Emulator is also having its own phone number.
In DDMS perspective You will see Emulator Control tab you can emulate the call from there.
If you don't see Emulator Control there . Use Window> Show /View > Emulator Control to make the tab appear.
To accesss device phone number in your code use telephonymanager.getLine1Number();
You need to set READ_PHONE_STATE permission in manifest file for that.
you cannot call the emulator from your device. But you can make calls to two emulators. For details on how to ? you can go to DDMS perspective then Emulator Control tab you can make the call from there to other emulator.
http://developer.android.com/tools/devices/emulator.html
Does anyone know if its possible to set the emulator's mobile number? I have not been able to find information about this anywhere. Thanks.
Mostly full control of the phone number detailed at the end of this blog:
http://blog.talosintel.com/2013/04/changing-imei-provider-model-and-phone.html
First 7 are fully configurable, last 4 can be one of 16 allowed port numbers.
It turns out that the phone number is stored on the SIM card. Since there is no actual SIM card, one is emulated. This emulated SIM is hard coded in the emulator-arm binary. The reason replacements for 1555521 failed is because SIM cards have a specification that does not store the MSISDN (Mobile Subscriber Integrated Services Digital Network-Number, AKA phone number) in plain text. Instead, each set of digits is swapped in some reverse nibbled endianness nightmare.
...
A quick way to find the MSISDN is to search for %d%df%d in the binary (highlighted in red below). The corresponding source code is in external/qemu/telephony/sim_card.c on line 436 in the current repo. The following is the format string portion of that sprintf:
"+CRSM:144,0,ffffffffffffffffffffffffffffffffffff0781515525%d1%d%df%dffffffffffff"
The interesting part is 515525%d1 (highlighted in blue). Swapping each set of two digits produces 1555521%d (thanks again CodePainters). That looks like the prefix to our mobile number.
Edit it in a hex editor.
I think this webpage will show you how to do it
https://www.wikihow.com/Find-Your-Phone-Number-on-Android
here instead of about phone try searching about the emulator device
You can simulate incoming SMS and calls in the simulator (using the simulator's port) but that's all, you can not set a device number or anything like that. For that kind of thing you will need a real device.
As I have found each emulator already has a phone number. If you run two emulators you can call from one emulator to another. To find out this phone numbers you can run in the terminal window:
Path\To\Your\Android\Sdk\platform-tools>adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
First phone number is +15555215554, second +15555215556, i.e. phone number is prefix +1555521 plus emulator suffix 5554 or 5556.
In your emulated device, press on the 3 dots highlighted in yellow and choose phone and then you can change the mobile number, screenshot attached in link below
https://i.stack.imgur.com/zhbSV.png
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
// get IMEI
String imei = tm.getDeviceId();
System.out.println("gfvnchgjvbnvhjbbnvgjvbncghvmn ngvm"+imei);
// get SimSerialNumber
String simSerialNumber = tm.getSimSerialNumber();
System.out.println("854755745588954754855ngvm"+simSerialNumber);
//get SimCardNumber
String number = tm.getLine1Number();
System.out.println("gfch5652345651szdxfcgvhbjnfcgvh ngvm"+number);
And Import :]->
import android.content.Context;
import android.telephony.TelephonyManager;
The mobile number of an emulator is the port number of that emulator. For more details. please check this link:
http://developer.android.com/guide/developing/devices/emulator.html#calling