android test review

  1. Which of the following is not Content Provider?

    • answer: Shared Preferences
    • Android系統一共提供了四種數據存儲方式。分別是:SharePreference、SQLite、Content Provider和File。
  2. Which of the following statements are correct with regards to signing applications?

    • No certificate authority is needed.
    • Android requires that all apps be digitally signed with a certificate before they can be installed. You can use self-signed certificates to sign your applications. No certificate authority is needed.
    • When you are ready to release your application to users, you must sign it with a suitable private key on your own. You cannot publish an application that is signed with the debug key generated by the SDK tools.
  3. Which of the following is correct to use for data transfer regularly and efficiently, but not instantaneously?

    • answer: Sync adapters
    • 如果我們的應用從服務器傳輸數據,且服務器的數據會頻繁地發生變化,那麼可以使用一個 Sync Adapter 通過下載數據來響應服務端數據的變化。要運行 Sync Adapter,我們需要讓服務端嚮應用的 BroadcastReceiver 發送一條特殊的消息。爲了響應這條消息,可以調用 ContentResolver.requestSync() 方法,向 Sync Adapter 框架發出信號,讓它運行 Sync Adapter。
  4. What is the best way of opening camera as sub-activity?

    static final int REQUEST_IMAGE_CAPTURE = 1;
    private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
    }
    }
  5. What is the correct way to restrict app visibility on Google Play to devices that have a camera?

    • uses-feature android:name=”android.hardware.camera” android:required=”true” />
    • 如果某個特性被顯式聲明爲必需的,則 Google Play 會把該特性加入應用程序的需求列表中。 然後,它會在不支持該特性的用戶設備上濾除這些應用程序。 例如:
  6. Which of the following permissions and configurations must be added in manifest file for implementing GCM Client?

    • permission.C2D_MESSAGE must
    • com.google.android.c2dm.permission.SEND must
    • GcmListenerService
    • InstanceIDListenerService
    • android.permission.WAKE_LOCK optional
    • android:minSdkVersion=”8”
    • android.permission.GET_ACCOUNTS optinal
      It uses an existing connection for Google services. For pre-3.0 devices, this requires users to set up their Google account on their mobile devices. A Google account is not a requirement on devices running Android 4.0.4 or higher.
  7. What is the advantage of using AsyncTaskLoader instead of AsyncTask?
    • less work with the configuration of application
    • AsyncTaskLoader不需要寫代碼來處理activiy 配置(系統字體大小,orientation,輸入設備類型等都叫做activity的配置)變化帶來的影響,但是缺點是加載時候不能解散掉進度框,不能在onLoadFinished時切換fragment.單純的從load data 角度考慮,AsyncTaskLoader更合適。
    • If you need UI changes after data is loaded - AsyncTask might server you better, especially if you are working with fragments, but remember to handle activity configuration changes.
    • AsyncTaskLoader是基於AsyncTask的 ,他不僅可以異步(通俗理解就是又開了一個線程而已),並且當他檢測到數據的變化時會自動加載。
  8. Which of the following statements are correct with regards to running of the Sync Adapter?

    • Running sync adapter periodically by setting a period of time to wait between runs, or by running it at certain times of the day, or both.
  9. Which of the following protocols are provided by Google for GCM Connection Servers?

    • Currently GCM provides two connection server protocols: HTTP and XMPP. Your app server can use them separately or in tandem.
  10. Which of the following 4 classes does not relate to others?
    • ApplicationInfo :Information you can retrieve about a particular application. This corresponds to information collected from the AndroidManifest.xml’s application tag.
    • SyncInfo: Information about the sync operation that is currently underway.
    • ActivityInfo: Information you can retrieve about a particular application activity or receiver. This corresponds to information collected from the AndroidManifest.xml’s activity> and receiver> tags.
    • PackageInfo: Overall information about the contents of a package. This corresponds to all of the information collected from AndroidManifest.xml.
  11. Which of the following classes is not used in working with database?

    • SQLiteOpenHelper: 可以創建數據庫,和管理數據庫的版本。
    • SQLiteDatabase: Exposes methods to manage a SQLite database. SQLiteDatabase has methods to create, delete, execute SQL commands, and perform other common database management tasks.
    • ContentProvider
    • DatabaseHelper: doesn`t exist
  12. Which of the following statement is correct regarding StrictMode?

    • StrictMode detects improper layouts
    • StrictMode detects operation which blocks UI
    • StrictMode detects the speed of the connection
    • StrictMode最常用來捕捉應用程序的主線程,它將報告與線程及虛擬機相關的策略違例。一旦檢測到策略違例(policy violation),你將獲得警告,其包含了一個棧trace顯示你的應用在何處發生違例。除了主線程,我們還可以在Handler,AsyncTask,AsyncQueryHandler,IntentService等API中使用StrictMode。
  13. MediaPlayer mp = new MediaPlayer(); before mp.start();

    • A MediaPlayer object must first enter the Prepared state before playback can be started.
    • There are two ways (synchronous vs. asynchronous) that the Prepared state can be reached: either a call to prepare() (synchronous) which transfers the object to the Prepared state once the method call returns, or a call to prepareAsync() (asynchronous) which first transfers the object to the Preparing state after the call returns (which occurs almost right way) while the internal player engine continues working on the rest of preparation work until the preparation work completes. When the preparation completes or when prepare() call returns, the internal player engine then calls a user supplied callback method, onPrepared() of the OnPreparedListener interface, if an OnPreparedListener is registered beforehand via
  14. if (intent.action == Intent.CALL_ACTION)

    • answer: When an outgoing phone call is initiated on the device.
    • 很多的時候 DIAL_ACTION 打開 Andriod撥號盤,
    • CALL_ACTION 將會啓動電話的呼叫過程並且開始呼叫提供的號碼
  15. Which of the following are true about enabling/disabling menu items from an Activity class?

    • answer: onPrepareOptionsMenu can be used to enable/disable some menu items in an Android application.
    • Once the activity is created, the onCreateOptionsMenu() method is called only once
    • If you want to change the Options Menu any time after it’s first created, you must override the onPrepareOptionsMenu() method. This passes you the Menu object as it currently exists. This is useful if you’d like to remove, add, disable, or enable menu items depending on the current state of your application.
  16. SimpleAdapter

    • An easy adapter to map static data to views defined in an XML file. You can specify the data backing the list as an ArrayList of Maps. Each entry in the ArrayList corresponds to one row in the list.
  17. SimpleCursorAdapter

    • An easy adapter to map columns from a cursor to TextViews or ImageViews defined in an XML file.
      String sql = "select _id,name,age from test_table";
          //得到一個Cursor,這個將要放入適配器中
      Cursor cursor = dbManager.executeSql(sql, null);
          // 最後一個參數flags是一個標識,標識當數據改變調用onContentChanged()的時候,是否通知ContentProvider數據的改變,如果無需監聽ContentProvider的改變,則可以傳0。
      SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.item, cursor, new String[] { "name", "age" }, new int[] { R.id.name, R.id.age }, 0);        
      ListView listView = (ListView) findViewById(R.id.listView);
      listView.setAdapter(adapter);
  18. Which of the following are true about PhoneStateIntentReceiver.notifyPhoneCallState?

  19. How many expansion files can an APK file have? Select all correct options.

    • You can store two expansion files per application. Each expansion file can be up to 2GB in size. APK files have a maximum file size, based on the Android …
  20. store custom message codes about the Message?

    • what: User-defined message code so that the recipient can identify what this message is about.
  21. markup

    • HTML is basically the web’s standard mark-up language, but it’s rather verbose.
    • Markdown is a specific markup library: http://daringfireball.net/projects/markdown/
    • What is the interface Spannable used for?
    • This is the interface for text to which markup objects can be attached and detached.
  22. PackageManager.getPackageInfo() returns information about the package, and PackageInfo.applicationInfo field has required information about the application.

  23. Which of the following attributes in the manifest file defines version information of an application for the Google Play Store (as opposed to defining version information for display to users)?

    • Google爲APK定義了兩個屬性:VersionCode和VersionName,他們有不同的用途。
    • VersionCode:對消費者不可見,僅用於應用市場、程序內部識別版本,判斷新舊等用途。
    • VersionName:展示給消費者,消費者會通過它認知自己安裝的版本,下文提到的版本號都是說VersionName。
  24. select the two function calls that can be used to start a service from your android application?

    • BindService和Started Service都是Service,有什麼地方不一樣呢:
    • Started Service中使用StartService()方法來進行方法的調用,調用者和服務之間沒有聯繫,即使調用者退出了,服務依然在進行【onCreate()- >onStartCommand()->startService()->onDestroy()】,注意其中沒有onStart(),主要是被onStartCommand()方法給取代了,onStart方法不推薦使用了。
    • BindService中使用bindService()方法來綁定服務,調用者和綁定者綁在一起,調用者一旦退出服務也就終止了【onCreate()->onBind()->onUnbind()->onDestroy()】。
  25. which of the following are valid features that you can request using requestwindowfeature?
    • FEATURE_NO_TITLE
    • FEATURE_RIGHT_ICON
發佈了31 篇原創文章 · 獲贊 4 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章