Questions and Answers about Android

How do we tell Android that we'd like a menu item to show up as a button on the Toolbar?
Add the showAsAction XML attribute to the menu item.


<menu xmlns:android="http://schemas.android.com/apk/res/android"   
      xmlns:app="http://schemas.android.com/apk/res-auto">
    <item        
       android:title="@string/search"        
       android:orderInCategory="1"       
       app:showAsAction="ifRoom"
       android:id="@+id/action_search"/>
</menu>

Which of the following activities can only be done after declaring a uses-permission in the manifest (rather than by using a system app)? 
Hint: Take a moment to explore http://developer.android.com/guide/topics/security/permissions.html
  • Taking a photo
  • Making a phone call
  • Getting the user’s current location <-- The answer
  • Accessing the details for a contact the user selects from the contact manager
Which methods are run on the main UI thread ? execute() -->True onPreExecute() onProgressUpdate() onPostExecute() publishProgress ->Wrong doInBackground()


What is the Adapter responsible for? Place a check next to each statement that is true: 

The adapter does create ViewHolder objects and inflates item views in its onCreateViewHolder function, it also returns the number of items in the data source, and binds data from the data source to each item (even if we pass the responsibility to the ViewHolder). It doesn't cache views associated with each item (that's the job of the ViewHolder class) nor does it recycle them; that’s what our RecyclerView does.

-Creating a ViewHolder object for each RecyclerView item.
-Returning the number of items in the data source
-Binding data from the data source to each item
-Inflating each item view that will be displayed
xCaching the views associated with each item
xRecycling items so they can be used again


**Corrects are red colored.**

Which of the following actions would be executed with an implicit intent ?
xOpening a web link
-Opening an activity in your app
xSharing a content from an app to Twitter
Opening a web link would be an implicit intent because you aren’t specifying a specific browser to use, the user gets to choose.
Opening an activity uses an explicit intent because you know exactly where to go.
Sharing content to Twitter is a bit of a curveball. We’ve taught you the best way to do it using an implicit intent. It is possible as an explicit intent but not recommended.
Why use an AsyncTaskLoader for threads bound to an Activity rather than AsyncTask?
AsyncTaskLoader will deliver the result to the current active Activity
AsyncTaskLoader prevents duplication of background threads
AsyncTaskLoader makes background threads run faster
AsyncTaskLoader helps eliminate duplication of zombie activities







Yorumlar

Bu blogdaki popüler yayınlar

About Android padding, margin, width, height, wrap_content, match_parent, R Class

@SerializedName and @Expose annotations