• What is the name of the IDE we are using?
  • Android 7.0, named Nougat, was released several years ago. What is the latest non-preview version of Android, what is its name, and what is the newest API? (Note: Q is a beta, so it is considered a preview.)
  • Name five SDK tools at your disposal when programming in Android Studio.
  • Name the four core components used in Android applications.
  • Why is the manifest file the foundation for every Android App? Give at least four reasons.
  • Why should you use a @string resource for TextViews instead of hardcoding the string?
  • When doing group projects, what is a good way to distribute source code with your teammates?
  • What can you use to run your Android apps if you don't have a device?
  • What is an Activity?
  • This question is related to Java, which is used in this course and is part of understanding the code we use in our apps. Consider the code between the long comments below. setOnClickListener takes an anonymous inner class which is an instantiation of the View.OnClickListener interface. Replace the code between the long comments with code (in only the exact same location) which uses an inner class named MyClass, instead of an anonymous inner class, to accomplish the same code results. More specifically, setOnClickListener should take an instantiation of MyClass name A.
public class MyActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_layout_id);
final Button button = findViewById(R.id.button_id);
//////////////////////////////////
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// CODE
}
});
//////////////////////////////////
}
}
  • What is a Layout?
  • Why use XML based layouts?
  • Consider the code below:
< button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/button"
android:text=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
  • What does the '+' character do?
  • Consider the code below:
< button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/button"
android:text=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
  • What does the '@' character do?
  • A(n) ______ is an interface in the View class that contains a single call back method.
  • What is a View?
  • If you want to center a view. Which attribute/property will you set?
  • For a LinearLayout, what is orientation, what are the possible values, how do they effect the Views added to them?
  • Name three layouts besides a LinearLayout.
  • What is the difference between margin and padding?
  • Write all the android:inputType attributes that occur in the list below.
    • number
    • inter_word
    • marquee
    • decimal
    • integer
    • signed
    • bold
    • date
    • time
    • italic
    • normal
    • datetime
    • center
    • fill
    • text
    • screen
    • words
    • sentences
    • web
    • email
    • phone
  • Given the following code
< LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
< View
android:layout_height="0dip"
android:layout_width="match_parent"
android:layout_weight="2" />
< View
android:layout_height="0dip"
android:layout_width="match_parent"
android:layout_weight="3" />
< View
android:layout_height="0dip"
android:layout_width="match_parent"
android:layout_weight="5" />
< /LinearLayout>
  • Describe the relationship between the Views. Focus on how they will be drawn to the screen.
  • Why use a RelativeLayout as opposed to a LinearLayout? Think about the View Heirarchy of more complex layouts. What is the major advantge you will get.tt
  • Suppose you have more content to display than you have area on the screen. What type of View might you consider putting everything in?
  • What is an Adapter? What is its purpose?
  • What is the significance of the "android.R"? What is it? Where? Why use it? Difference between just 'R'?
  • Name an Android app that is amongst the Top 100 Free Apps in Google Play Store that uses a GridView. Explain why. For reference, here is a ranked link of the top free app in the Google Play Store.
  • What is a ViewFlipper? When would you want to use it?
  • You just created a project. The only thing you've done so far is add a ListView to the canvas. How do you populate the ListView using XML (2 step process)?
  • How do you pass data from one Activity A to another Activity B?
  • What type of Layout does a WebView extend?
  • Which function, from the list below, do you call when you want to kill your Activity? This call is made from inside the Activity.
    • finalize()
    • onDestroy()
    • finish()
    • onStop()
    • onKill()
  • Your screen was just rotated. How does this effect your Activity? What happens to your life cycle?
  • Assume the scenario listed below. Write which life cycle states (i.e. on-Functions) occur throughout the scenario, in order, and explain when they occur (i.e. are called). Scenario: You just started a game and we're interrupted by a phone call. After the call you go back to the game and select quit.
  • What you happen to the data in your View when the screen was rotated? Any problems? How would they be fixed if they were?
  • How can you tell the system you don't want it's help with screen rotation? XML attribute? Method Implementation?
  • Are you able to force your app into a certain screen orientation? How or why not?
  • When dealing with the main process thread, what's the main issue to be concerned with? It's a big no no. What happens to the app and the user if we don't obey it?
  • What are two ways to implement a thread? How are these threads different from each other?
  • Suppose we have two threads that need to talk to each other (e.g. a thread reporting the progress of a download). Fill-in-the-blank. We create ______ to pas ______ back and forth.
  • What are the two types of intent resolution? How are they different? Why use one of the other?
  • What happens if two or more intents are resolved to the same intent filter? What does the system or user do?
  • Suppose your app is not able to access the internet in the emulator. What could be the problem? You are 100% sure that your computer and other apps on the emulator have internet connection.
  • What is LogCat? When would we use it? Why?
  • What is the purpose of Fragments? Or, given an example of how Fragments can be useful.
  • Concerning Fragments, what should be returned in onCreateView() if you choose to implement this method?
  • What's the purpose of a BroadcastReceiver? Or describe a BroadcastReceiver.
  • What are the 2 ways that you can register a BroadcastReceiver? Give pseudocode.
  • Apps like Facebook and WhatsApp allow you to communicate with people that are in your Android Device's contacts. For example, WhatsApp may scan your contacts to determine if any of your contacts are also using WhatsApp. You're trying to develop an app that works similar to WhatsApp. Unfortunately, your Java code that is supposed to read your contacts doesn't seem to work. In the scope of lecture 6, why doesn't it work, assuming that the problem is NOT with the Java code.
  • What is a Preference? Why do we use it? When?
  • What makes it Shared? Preference vs SharedPreference? Are there even any differences?
  • What do you use to fetch your app's SharedPreferences? Choose the correct answer from the list below:
    • GetSharedPreferences
    • SharedPreferenceGetter
    • PreferenceManager
    • SharedPreferenceManager
    • PreferenceFactory
  • What types of things should you *NOT* store in a Preference? Give some examples.
  • Describe the LifeCycle of a BroadcastReceiver. How is it different than an Activity? What can you NOT do in the onReceiver method (i.e. doing this will crash your app)?
  • How can you make your BroadcastReceiver receive intents? List all correct answers from a-f below.
    • a. Fill out the receive tag as a child of Activity in the manifest.
    • b. Fill out the receive tag as a child of Application in the manifest.
    • c. Create a new Broadcast receiver with IntentFilter and register it with a Context in the Java code
    • d. Get it from the BroadcastReceiverManager
    • e. All of the above
    • f. None of the above
  • Which permission, from list below, do you need to receive a picture message?
    • android.permission.RECEIVE_SMS
    • android.permission.SEND_SMS
    • android.permission.RECEIVE_WAP_PUSH
    • android.permission.WAKE_LOCK
    • android.permission.RECEIVE_MMS
    • android.permission.READ_SYNC_STATS
    • android.permission.INTERNET
  • From the list a-g below, to get a NotificationManager what method(s) can you call?
    • a. getNotificationManager()
    • b. getSystemService(Context.NOTIFICATION_SERVICE)
    • c. getNotificationService(Context.NOTIFICATION_SERVICE)
    • d. getSystemService(NotificationManager.class)
    • e. getNotificationManager(this)
    • f. All of the Above
    • g. None of the Above
  • What is a PendingIntent? What is it used for? How is it different from a regular Intent?
  • Suppose you have a static string that you want to display. Where should the good Android programmer put it? Why?
  • How would you get what's stored inside of a string? Suppose the name of the string is hello. And you are inside of an Activity. Choose from the list a-g below.
    • a. getString(R.string.hello)
    • b. Context.getString(R.string.hello)
    • c. (String) findViewById(R.id.hello)
    • d. (String) Context.findViewById(R.id.hello)
    • e. (String) inflater.inflate(R.id.hello, null)
    • f. (String) inflater.inflate(R.string.hello, null)
    • g. getString(R.id.hello)
  • What are some other peices of information that you can store similar to a string? Wha other types of data can you store exactly like you store a string?
  • Write the code to get an integer shared preference called "value", change the value, and save it back.
  • Besides putting a notification in the system's sliding tray, what are some other ways you can notify the user? Think hardware.
  • Explain what a Service is.
  • What's the difference between a regular Service and an IntentService?
  • What are some ways that you can communicate with your Service?
  • If you have a task that needs to be done which has a lot of work involved, but does not (or hardly needs to) update the UI, how do you determine whether to use a Service - which will be started from an Activity - or a separate thread (such as an AsyncTask) - which will be started from an Activity?
  • Name the three ways to create a Bound Service.
  • Which function is called when a Messenger receives a new message?
  • True or False: The following code gives a handle to the SensorManager: SensorManager sm = getSystemService(SENSOR_SERVICE); Cit your source. If false, give the correct answer.
  • Give the function that returns the result for an Activity started with startActivityForResult() Give the function name and arguments.
  • If the device has multiple components that handle the following intent, which is selected? Intent intent = new Intent(Intent.ACTION_VIEW, URI.parse("http://www.google.com"));
    • The first component the Android system finds
    • The last component the Android system find
    • All of the components
    • None of the above
  • What is a Content Provider?
  • Why would a ContentProvider be used instead of SharedPreferences? Provide an example which would require a ContentProvider.
  • What is the object type returned by getContentResolver.query()?
  • Which character is used as a placeholder for a value in a query? This character is replaced by the value when the query is executed.
  • For an application with package "cs.quiz5", how would you construct the Uri for the ContentProvider? Give the string passed to Uri.parse(...).
  • ContentProviders contain an inner class to help with certain tasks. What class does this inner class extend and what are the tasks it takes care of?
  • A database object is obtained by getWritableDatabase(). Which ContentProvider function(s), from the list below, can this database be properly used with?
    • Uri.insert(Uri uri, ContentValues values)
    • Uri.update(Uri uri, ContentValues values, String selection, String[] selectionArgs)
    • Uri.delete(Uri uri, String whereClause, String[] whereArgs)
    • Cursor.query(Uri table, String[] columns, String selection, String[] args, String orderBy)
  • True or false: When you create a ContentProvider, by default anyone can read from it. Cite your source(s).
  • True or false: When you create a ContentProvider, by default no one can write to it. Cite your source(s).
  • True or false: If an external app includes permission "contentproviderexample.permission.ALL_PERMISSION", it can read the ContentProvider from package contentproviderexample.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.