@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences prefs = getPreferences(MODE_PRIVATE); String udnPref = prefs.getString("UDN", null); if (udnPref != null) { // we have a stored UDN, so use it udn = new UDN(udnPref); Log.i("udn", "old udn: " + udn.toString()); } else { // we need to generate a udn and store it udn = new UDN(UUID.randomUUID()); Log.i("udn", "new udn: " + udn.toString()); SharedPreferences.Editor editor = prefs.edit(); editor.putString("UDN", udn.getIdentifierString()); editor.commit(); } mDataStoreInterfaceImpl = new DataStoreInterfaceImpl(getContentResolver()); setContentView(R.layout.activity_main); final ImageView fridgeImg = (ImageView) findViewById(R.id.imageView1); fridgeImg.setOnClickListener( new View.OnClickListener() { private boolean fridgeState; public void onClick(View v) { if (fridgeState) { fridgeImg.setImageResource(R.drawable.fridge_closed); fridgeState = false; mDoorOpenAlarm.resetAlarm(); } else { fridgeImg.setImageResource(R.drawable.fridge_off); fridgeState = true; mDoorOpenAlarm.setAlarm(); } } }); mSensorChangedLed = (Led) findViewById(R.id.redled); mSensorReadLed = (Led) findViewById(R.id.greenled); setupSensorNetwork(); // setText(); }
public void showAboutDialog() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); // set title alertDialogBuilder.setTitle(APP_ABOUT_TITLE); // set dialog message String message = APP_ABOUT_MESSAGE + "\n" + udn.toString(); alertDialogBuilder .setMessage(message) .setCancelable(false) .setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) {} }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }