Custom views and directional controller clicks. In general, you should send an AccessibilityEvent whenever the content of your custom view changes. For example, if a text value was changed in your custom view, you should emit an event of this type:
Assume that you have the following situation: The app code calls for R.string.text_a Three relevant resource files are available:
-res/values/strings.xml, which includes text_a in the app's default language, in this case English.
-res/values-mcc404/strings.xml, which includes text_a in the app's default language, in this case English.
-res/values-hi/strings.xml, which includes text_a in Hindi.
The app is running on a device that has the following configuration:
-The SIM card is connected to a mobile network in India (MCC 404).
-The language is set to Hindi (hi).
Which is the correct statement below?
Assume that an app includes a default set of graphics and two other sets of graphics, each optimized for a different device setup:
res/drawable/
Contains default graphics. res/drawable-small-land-stylus/
Contains graphics optimized for use with a device that expects input from a stylus and has a QVGA low- density screen in landscape orientation.
res/drawable-ja/
Contains graphics optimized for use with Japanese.
What happens if the app runs on a device that is configured to use Japanese and, at the same time, the device happens to be one that expects input from a stylus and has a QVGA low-density screen in landscape orientation?
When using an EditTexts or editable TextViews, or other editable View. What attribute to use to provide a content label for that View?
A content label sometimes depends on information only available at runtime, or the meaning of a View might change over time. For example, a Play button might change to a Pause button during music playback. In these cases, to update the content label at the appropriate time, we can use:
What happens when you create a DAO method and annotate it with @Insert?
Example:
@Dao
public interface MyDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
public void insertUsers(User... users);
}
Custom duration in milliseconds as a parameter for the setDuration method is available when you are working with:
What method should we use with Notification.Builder to supply a PendingIntent to be sent when the notification is clicked?
Relative positioning is one of the basic building blocks of creating layouts in ConstraintLayout. Constraints allow you to position a given widget relative to another one. What constraints do not exist?
If constant LENGTH_INDEFINITE is used as a parameter for the setDuration method in Snackbar, what will happen?
For example, our preferences.xml file was added by addPreferencesFromResource (R.xml.preferences). Our preferences.xml file contains such item:
android:title="@string/pref_notification_title" android:summary="@string/pref_notification_summary" android:defaultValue="@bool/pref_notification_default_value" app:iconSpaceReserved="false"/> In our Fragment, we can dynamically get current notification preference value in this way:
For example, we have a BufferedReader reader, associated with the json file through
InputStreamReader. To get a file data we can do this:
Room can export your database's schema information into a JSON file at compile time. What annotation processor property you should set in your app/build.gradle file to export the schema?
The Layout Inspector in Android Studio allows you to compare your app layout with design mockups, display a magnified or 3D view of your app, and examine details of its layout at runtime. When this is especially useful?
In a class PreferenceFragmentCompat. What method is called during onCreate(Bundle) to supply the preferences for this fragment. And where subclasses are expected to call setPreferenceScreen (PreferenceScreen) either directly or via helper methods such as addPreferencesFromResource (int)?
What do you want from Room when you create a DAO method and annotate it with @Update?
Example:
@Dao
interface MyDao {
@Update
fun updateUsers(vararg users: User)
}
An overridden method onCreateOptionsMenu in an Activity returns boolean value. What does this value mean?
Custom views and directional controller clicks. On most devices, clicking a view using a directional controller sends (to the view currently in focus) a KeyEvent with:
What do you want from Room when you create a DAO method and annotate it with @Delete?
Example:
@Dao
public interface MyDao {
@Delete
public void deleteUsers(User... users);
}
For example, we have a file in our raw folder app/src/main/res/raw/sample_teas.json. To get an
InputStream for reading it, from out Context context, we can do this:
SharedPreferences.Editor is an interface used for modifying values in a SharedPreferences object. All changes you make in an editor are batched, and not copied back to the original SharedPreferences until you call:
@Query is the main annotation used in DAO classes. It allows you to perform read/write operations on a database. Each @Query method is verified at compile time, so what happens if there is a problem with the query?
The Log class allows you to create log messages that appear in logcat. Generally, you could use the following log methods: (Choose five.)
An example. In our ViewModelFactory (that implements ViewModelProvider.Factory) we have an instance of our Repository, named mRepository. Our ViewModel has such constructor:
class MyViewModel(private val mRepository: MyRepository) : ViewModel() ...
Next, in our ViewModelFactory create ViewModel method (overriden) looks like this:
override fun
return try {
//MISSED RETURN VALUE HERE”
} catch (e: InstantiationException) {
throw RuntimeException("Cannot create an instance of $modelClass", e)
} catch (e: IllegalAccessException) {
throw RuntimeException("Cannot create an instance of $modelClass", e)
} catch (e: NoSuchMethodException) {
throw RuntimeException("Cannot create an instance of $modelClass", e)
} catch (e: InvocationTargetException) {
throw RuntimeException("Cannot create an instance of $modelClass", e)
}
}
What should we write instead of “//MISSED RETURN VALUE HERE”?
For example, we have a file in our assets folder app/src/main/assets/sample_teas.json. To get an InputStream for reading it, from out Context context, we can try do this:
Interface for a callback to be invoked when a shared preference is changed. Interface is named:
As an example. In an Activity we have our TimerViewModel object (extended ViewModel), named mTimerViewModel. mTimerViewModel.timer method returns a LiveData
Filter logcat messages. If in the filter menu, a filter option “Show only selected application”? means:
For example, our preferences.xml file was added by addPreferencesFromResource (R.xml.preferences). Our preferences.xml file contains such item:
android:title="@string/pref_notification_title" android:summary="@string/pref_notification_summary" android:defaultValue="@bool/pref_notification_default_value" app:iconSpaceReserved="false"/> In our Fragment, we can dynamically get current notification preference value in this way:
In a class extended PreferenceFragmentCompat. What method is used to inflate the given XML resource and add the preference hierarchy to the current preference hierarchy?
Content labels. What attribute to use to indicate that a View should act as a content label for another View?
Android uses adapters (from the Adapter class) to connect data with View items in a list. There are many different kinds of adapters available, and you can also write custom adapters. To connect data with View items, the adapter needs to know about the View items. From what is extended the entity that is usually used in an adapter and describes a View item and its position within the RecyclerView?