MAD Prelim Answers
MAD Prelim Answers
d) DatePicker example:
DatePickerDialog datePickerDialog = new DatePickerDialog(this, (view, year, month,
day) -> {
dateTextView.setText(day + "/" + (month + 1) + "/" + year);
}, year, month, day);
datePickerDialog.show();
<LinearLayout>
<CheckBox android:id="@+id/cb1" android:text="Option 1"/>
<CheckBox android:id="@+id/cb2" android:text="Option 2"/>
...
<Button android:onClick="showSelected" android:text="Submit"/>
</LinearLayout>
FusedLocationProviderClient locationClient =
LocationServices.getFusedLocationProviderClient(this);
locationClient.getLastLocation().addOnSuccessListener(location -> {
double lat = location.getLatitude();
double lon = location.getLongitude();
});
c) Program to send email:
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"example@mail.com"});
email.putExtra(Intent.EXTRA_SUBJECT, "Subject");
email.putExtra(Intent.EXTRA_TEXT, "Body");
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose Email Client"));