- Android & Kotlin Examples code
- how to get device model name programmatically in Android Kotlin
- Android.os.Build.MODEL
- Android Device Information Generator Online
- To get an Android Device Information including device Model, device Type(smartphone or tablet), brand, manufacturer, android Version and etc Easily and quickly.
- What is Android Device ID?
- How to know your Android Device ID?
- How to get Android device hardware information like processor architecture, RAM, etc?
- What is IMSI?
- What is the difference of IMEI and IMSI?
- Android & Kotlin Examples code
- how to get device model name programmatically in Android Kotlin
- Android.os.Build.MODEL
- How to get an Android Device Nickname
- A Comparison of the Top 5 Methods on Popular Android Devices
- Background
- Research
- Results
- Conclusion
Android & Kotlin Examples code
Android kotlin tutorials and examples code for android apps developers.
how to get device model name programmatically in Android Kotlin
Android.os.Build.MODEL
public static final String MODEL, Added in API level 1
The end-user-visible name for the end product.
Android java function getDeviceName() code:
Utils.java :
import android.os.Build
class K_utils <
companion object <
@JvmStatic
fun getPhoneDeviceName():String <
val model = Build.MODEL // returns model name
return model;
>
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import com.example.espl.myapplication.K_utils.Companion.getPhoneDeviceName
import com.example.espl.myapplication.Utils.getDeviceName
class MainActivity : AppCompatActivity() <
override fun onCreate(savedInstanceState: Bundle?) <
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val tv_java_utils_output: TextView = findViewById(R.id.tv_java_utils_output) as TextView
//using java function getDeviceName()
tv_java_utils_output.text = «Using java Function::»+getDeviceName();
//using kotlin function getPhoneDeviceName()
val tv_kotlin_utils_output: TextView = findViewById(R.id.tv_kotlin_utils_output) as TextView
tv_kotlin_utils_output.text =»Using Kotlin version of Function::»+getPhoneDeviceName();
>
>
xmlns:android=»http://schemas.android.com/apk/res/android»
xmlns:tools=»http://schemas.android.com/tools»
xmlns:app=»http://schemas.android.com/apk/res-auto»
android:layout_width=»match_parent»
android:layout_height=»match_parent»
android:gravity=»center_horizontal»
android:orientation=»vertical»
tools:context=».MainActivity»>
android:gravity=»center_vertical|center_horizontal»
android:layout_width=»wrap_content»
android:id=»@+id/tv_java_utils_output»
android:layout_height=»wrap_content»
android:padding=»10dp»
android:background=»@color/colorGray»
android:layout_margin=»10dp»
android:textColor=»@color/colorPrimary»
app:layout_constraintBottom_toBottomOf=»parent»
app:layout_constraintLeft_toLeftOf=»parent»
app:layout_constraintRight_toRightOf=»parent»
app:layout_constraintTop_toTopOf=»parent»/>
android:padding=»10dp»
android:layout_margin=»10dp»
android:textColor=»@color/colorPrimary»
android:id=»@+id/tv_kotlin_utils_output»
android:layout_width=»wrap_content»
android:layout_height=»wrap_content»
android:background=»@color/colorGray»
app:layout_constraintBottom_toBottomOf=»parent»
app:layout_constraintLeft_toLeftOf=»parent»
app:layout_constraintRight_toRightOf=»parent»
app:layout_constraintTop_toTopOf=»parent»/>
Output on HTC Desire 620G dual sim phone device model:
get android mobile phone model name programmatically — Kotlin |
android.os.Build.MANUFACTURER returns public static final String MANUFACTURER — Added in API level 4
The manufacturer of the product/hardware.
Similarly to get the device manufacturer name in android programmatically use below code that returns a manufacturer name as a string.
Источник
Android Device Information Generator Online
To get an Android Device Information including device Model, device Type(smartphone or tablet), brand, manufacturer, android Version and etc Easily and quickly.
Warning: mysql_connect(): Too many connections in /www/wwwroot/myfakeinfo/include/dbfunction.php on line 13
Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /www/wwwroot/myfakeinfo/include/dbfunction.php on line 14
Warning: mysql_query() expects parameter 2 to be resource, boolean given in /www/wwwroot/myfakeinfo/include/dbfunction.php on line 47
MySQL Error:
Too many connections
while executing query:
select CountryCode,OperatorName,CarrierName,MCCandMNC from operatorandcarrierinfo where isverify=1 order by id
Warning: mysql_num_rows() expects parameter 1 to be resource, integer given in /www/wwwroot/myfakeinfo/include/androidDeviceInfoGenerator.php on line 17
Warning: mysql_query() expects parameter 2 to be resource, boolean given in /www/wwwroot/myfakeinfo/include/dbfunction.php on line 47
MySQL Error:
Too many connections
while executing query:
select countryCode,c.languageCode as langCode,languageENName from countrylanguageinfo c,languageinfo l where c.languageCode=l.languageCode and c.countryCode=’US’
Warning: mysql_num_rows() expects parameter 1 to be resource, integer given in /www/wwwroot/myfakeinfo/include/androidDeviceInfoGenerator.php on line 43
Warning: mysql_query() expects parameter 2 to be resource, boolean given in /www/wwwroot/myfakeinfo/include/dbfunction.php on line 47
MySQL Error:
Too many connections
while executing query:
select TimeZoneID,TimeOffset,TimeZone from countrytimezoneinfo where countryCode=’US’
Warning: mysql_num_rows() expects parameter 1 to be resource, integer given in /www/wwwroot/myfakeinfo/include/androidDeviceInfoGenerator.php on line 65
Warning: mysql_query() expects parameter 2 to be resource, boolean given in /www/wwwroot/myfakeinfo/include/dbfunction.php on line 47
MySQL Error:
Too many connections
while executing query:
SELECT deviceid,product,model,brand,tac,macsuffix,ver_sdk,ver_release,device,type,screensize,phonetype FROM mobiledeviceinfo AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM mobiledeviceinfo)-(SELECT MIN(id) FROM mobiledeviceinfo))+(SELECT MIN(id) FROM mobiledeviceinfo)) AS randid) AS t2 WHERE t1.id >= t2.randid and isverify=1 and brand<>‘Xiaomi’ and brand<>‘Meizu’ ORDER BY t1.id LIMIT 50
Warning: mysql_num_rows() expects parameter 1 to be resource, integer given in /www/wwwroot/myfakeinfo/include/androidDeviceInfoGenerator.php on line 122
Warning: mysql_query() expects parameter 2 to be resource, boolean given in /www/wwwroot/myfakeinfo/include/dbfunction.php on line 47
MySQL Error:
Too many connections
while executing query:
SELECT deviceid,product,model,brand,tac,macsuffix,ver_sdk,ver_release,device,type,screensize,phonetype FROM mobiledeviceinfo AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM mobiledeviceinfo)-(SELECT MIN(id) FROM mobiledeviceinfo))+(SELECT MIN(id) FROM mobiledeviceinfo)) AS randid) AS t2 WHERE t1.id >= t2.randid and isverify=1 and brand<>‘Xiaomi’ and brand<>‘Meizu’ ORDER BY t1.id LIMIT 50
Warning: mysql_num_rows() expects parameter 1 to be resource, integer given in /www/wwwroot/myfakeinfo/include/androidDeviceInfoGenerator.php on line 136
What is Android Device 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.)
How to know your Android Device ID?
There are two ways to know your Android Device ID:
First Method: Enter *#*#8255#*#* in your phone dialer, you’ll be shown your android device ID.
Second Method: As another option, you can also use an Android app called “Android Device ID” that will quickly reveal the ID of your Android Device to you.
How to get Android device hardware information like processor architecture, RAM, etc?
You can get hardware properties like Android SDK, Android Version, Android Brand, Manufacturer’s name and Android model by Settings -> About Phone . It should tell you most of what you want to know. Failing that, it will at least tell you a model name which you can then search google for more info.
What is IMSI?
The International Mobile Subscriber Identity or IMSI is used to identify the user of a cellular network and is a unique identification associated with all cellular networks. It is stored as a 64 bit field and is sent by the phone to the network. It is also used for acquiring other details of the mobile in the home location register (HLR) or as locally copied in the visitor location register. To prevent eavesdroppers identifying and tracking the subscriber on the radio interface, the IMSI is sent as rarely as possible and a randomly generated TMSI is sent instead.
The IMSI is used in any mobile network that interconnects with other networks. For GSM, UMTS and LTE network, this number is provisioned in the SIM card and for CDMA2000 in the phone directly or in the R-UIM card (the CDMA2000 analogue to a SIM card for GSM).
An IMSI is usually presented as a 15 digit number, but can be shorter. For example, MTN South Africa’s old IMSIs that are still being used in the market are shown as 14 digits. The first 3 digits are the mobile country code (MCC), which are followed by the mobile network code (MNC), either 2 digits (European standard) or 3 digits (North American standard). The length of the MNC depends on the value of the MCC. The remaining digits are the mobile subscription identification number (MSIN) within the network’s customer base.
An IMSI is usually presented as a 15 digit number, but can be shorter. The first 3 digits are the mobile country code (MCC), which are followed by the mobile network code (MNC), either 2 digits (European standard) or 3 digits (North American standard).
IMSI consists of three parts:
- MCC — Mobile Country Code, first 3 digits. MCC uniquely identifies the mobile subscriber’s home country.
- MNC — Mobile Network Code, 2 digits (European standard) or 3 digits (North American standard). The length of the MNC depends on the value of the MCC.
- MSIN — the remaining digits are the Mobile Subscription Identification Number (MSIN) within the network’s customer base.
What is the difference of IMEI and IMSI?
The IMSI (International Mobile Subscriber Identity) is a code used by the phone company to identify the SIM (phone user) on the mobile network.
The IMEI (International Mobile Station Equipment Identity) is an international «Serial number» for your phone (device itself) to properly identify it on the carriers network.
Источник
Android & Kotlin Examples code
Android kotlin tutorials and examples code for android apps developers.
how to get device model name programmatically in Android Kotlin
Android.os.Build.MODEL
public static final String MODEL, Added in API level 1
The end-user-visible name for the end product.
Android java function getDeviceName() code:
Utils.java :
import android.os.Build
class K_utils <
companion object <
@JvmStatic
fun getPhoneDeviceName():String <
val model = Build.MODEL // returns model name
return model;
>
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import com.example.espl.myapplication.K_utils.Companion.getPhoneDeviceName
import com.example.espl.myapplication.Utils.getDeviceName
class MainActivity : AppCompatActivity() <
override fun onCreate(savedInstanceState: Bundle?) <
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val tv_java_utils_output: TextView = findViewById(R.id.tv_java_utils_output) as TextView
//using java function getDeviceName()
tv_java_utils_output.text = «Using java Function::»+getDeviceName();
//using kotlin function getPhoneDeviceName()
val tv_kotlin_utils_output: TextView = findViewById(R.id.tv_kotlin_utils_output) as TextView
tv_kotlin_utils_output.text =»Using Kotlin version of Function::»+getPhoneDeviceName();
>
>
xmlns:android=»http://schemas.android.com/apk/res/android»
xmlns:tools=»http://schemas.android.com/tools»
xmlns:app=»http://schemas.android.com/apk/res-auto»
android:layout_width=»match_parent»
android:layout_height=»match_parent»
android:gravity=»center_horizontal»
android:orientation=»vertical»
tools:context=».MainActivity»>
android:gravity=»center_vertical|center_horizontal»
android:layout_width=»wrap_content»
android:id=»@+id/tv_java_utils_output»
android:layout_height=»wrap_content»
android:padding=»10dp»
android:background=»@color/colorGray»
android:layout_margin=»10dp»
android:textColor=»@color/colorPrimary»
app:layout_constraintBottom_toBottomOf=»parent»
app:layout_constraintLeft_toLeftOf=»parent»
app:layout_constraintRight_toRightOf=»parent»
app:layout_constraintTop_toTopOf=»parent»/>
android:padding=»10dp»
android:layout_margin=»10dp»
android:textColor=»@color/colorPrimary»
android:id=»@+id/tv_kotlin_utils_output»
android:layout_width=»wrap_content»
android:layout_height=»wrap_content»
android:background=»@color/colorGray»
app:layout_constraintBottom_toBottomOf=»parent»
app:layout_constraintLeft_toLeftOf=»parent»
app:layout_constraintRight_toRightOf=»parent»
app:layout_constraintTop_toTopOf=»parent»/>
Output on HTC Desire 620G dual sim phone device model:
get android mobile phone model name programmatically — Kotlin |
android.os.Build.MANUFACTURER returns public static final String MANUFACTURER — Added in API level 4
The manufacturer of the product/hardware.
Similarly to get the device manufacturer name in android programmatically use below code that returns a manufacturer name as a string.
Источник
How to get an Android Device Nickname
A Comparison of the Top 5 Methods on Popular Android Devices
Background
On most Android devices, users have the option to set a custom device nickname to make it easier for them to identity their device. When showing a user a list of their devices, we want their custom device name to be displayed instead of the factory default value if it’s available.
Research
I searched the web and found several different methods to read the user specified device nickname on Android:
Note: #3 requires Bluetooth permission.
Results
But how do they perform on various popular Android devices? The # columns in the table below refer to the methods used to access the device nickname referenced in the ‘Research’ section above. A green check indicates that we were able to successfully read the user’s custom device nickname.
Conclusion
There is no standardized Android API to read the user specified device nickname and not all Android devices support a custom nickname. There are ways to read this data but none work on all Android devices.
Although we didn’t find a consistent way to access the user specified device nickname, there are libraries available like AndroidDeviceNames that can provide a more readable device name than the factory set value (e.g. “sailfish”). For example, it can provide “Samsung S8+” which a user is more likely to recognize than the codename “dream2qltecan” or model number “SM-G955W”.
DISCLOSURE STATEMENT: These opinions are those of the author. Unless noted otherwise in this post, Capital One is not affiliated with, nor is it endorsed by, any of the companies mentioned. All trademarks and other intellectual property used or displayed are the ownership of their respective owners. This article is © 2019 Capital One.
Источник