Hi friends,Today I'm going post
about how to Get device name,IMEI no,screen width,height and mobile
no.Few days ago I need to use this all in my recent project but could
not seen any tutorial which explains about this all.So have look on
code part it's pretty easy.Android provides us API for this all.
Code:public class Utility {
int sh, sw;
Context context;
DisplayMetrics metrics;
public AdParameters(Context context) {
// TODO Auto-generated constructor stub
this.context = context;
metrics = context.getResources().getDisplayMetrics();
}
public String getDeviceName() {
return android.os.Build.MODEL;
}
public String getIMEI() {
// TODO Auto-generated method stub
TelephonyManager telephonyManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return telephonyManager.getDeviceId();
// return (Secure.getString(context.getContentResolver(),
// Secure.ANDROID_ID));
}
public int getSw() {
// TODO Auto-generated method stub
return metrics.widthPixels;
}
public int getSh() {
return metrics.heightPixels;
}
public String getMobielNo() {
// TODO Auto-generated method stub
TelephonyManager tm = (TelephonyManager) context
.getSystemService(context.TELEPHONY_SERVICE);
return tm.getLine1Number();
}
}
Now you need to create an object of this class and then call appropriate method according to your requirement.
Comments
Post a Comment