package sg.vinova.vss.group5.non.activity; import sg.vinova.vss.group5.non.R; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.telephony.TelephonyManager; public class CheckSimChanged extends Activity{ public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); TelephonyManager telephoneMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String phoneNumber = telephoneMgr.getLine1Number(); AlertDialog dialBox = createDialogBox(phoneNumber); dialBox.show(); } private AlertDialog createDialogBox(final String phoneNumber){ AlertDialog myOptionBox =new AlertDialog.Builder(this) .setTitle("Option Box") .setMessage("Your phone number have changed. Would you want to send it to other contacts in your phone?") .setIcon(R.drawable.ic_launcher) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { announceNewPhone(phoneNumber); } }) .setNeutralButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }) .create(); return myOptionBox; } private void announceNewPhone(String phoneNumber){ Intent intent = new Intent(this, sendNewPhone.class); startActivity(intent); } }