Sapient Company Programming

The following code snippet will create a new alarm in Android. In order to invoke the ACTION_SET_ALARM intent, your app must have the SET_ALARM permission. Which of the followinig options correctly sets the SET_ALARM permission?

public void createAlarm(String message, int hour, int minutes){
Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM)
.putExtra(AlarmClock.EXTRA_MESSAGE, message)
.putExtra(AlarmClock.EXTRA_HOUR, hour)
.putExtra(AlarmClock.EXTRA_MINUTES, minutes);

if(intent.resolveActivity(getPackageManager()) != null){
startActivity(intent);
}
}

1)
2)
3)

Read Solution (Total 1)

Sapient Other Question

Which of the following statements is/are correct about Application Object?

A. The application object is created whenever an Android component starts.
B. The application object starts in a new process with a unique ID under a unique user.
C. The application obejct starts before any components and runs at least as long as another component of the application runs.

1) A, B and C
2) B and C
3) Only A
4) Only C
Which of the following statements about the content provider component of Android systems is/are correct?

A. Intents can be used to start a content provider.
B. Intents cannot start a content provider.
C. Content provider supports shared preferences.

1) Statement C is incorrect
2) Both the statements B and C are incorrect
3) Statement B is correct
4) All the statements are wrong