1. How to get Phone Number.
TelephonyManager telephonyManager = TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = telephonyManager.getLine1Number();
// Make sure you are requesting the correct permission in your manifest.
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
NOTE:it's working not All time some times not display any number.
2.How to Make Static Rotation/orientation in Android.
// if you want to lock screen
setRequestedOrientation(
// if you want to lock screen
setRequestedOrientation(
3. How to Create Alert Dialog Box in Android.
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("App has been started..")
.setCancelable(false)
.setTitle("Alert Box")
.setNegativeButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
4.Array list value Strore in Another Arraylist
private void AddDataToDB() {
ArrayList<DOBInfo> album_array = new ArrayList<DOBInfo>();
for (int i=0; i < album_array.size(); i++ ) {
DOBInfo value = album_array.get(i);
if(i<10) {
Log.i(TAG, " Added " +i);
database.createContact(value.getName(), value.getDays(), value.getDob(), value.getImg());
}
}
}
No comments:
Post a Comment