linkedin-skill-assessments-quizzes

Android

Q1. 要为您的 Android 应用添加功能、组件和权限,需要编辑哪个文件?

Q2. 应使用哪个 XML 属性使 Image View 可访问?

Q3. 您启动应用程序,当导航到新屏幕时应用崩溃,以下哪种操作无法帮助您诊断问题?

Q4. 为什么推送通知可能会停止工作?

Q5. 实现一个垂直显示小部件列表的 RecyclerView 所需的正确组件类集合是什么?

    RecycleView
    RecyclerView.Adapter<T extends BaseAdapter>
    RecyclerView.ViewHolder<T extends BaseViewHolder>
    LinearLayoutManager
    RecycleView
    RecyclerView.Adapter
    RecyclerView.ViewHolder<T extends BaseViewHolder>
    LinearLayoutManager
    RecycleView
    RecyclerView.Adapter
    RecyclerView.ViewHolder
    LinearLayoutManager
    RecycleView
    RecyclerView.Adapter<VH extends ViewHolder>
    RecyclerView.ViewHolder
    LinearLayoutManager

Q6. 当 Android 系统需要释放内存时,会终止进程。系统终止某个进程的可能性取决于进程的状态和活动的状态。哪种进程和活动状态组合最有可能被终止?

Q7. 您创建了一个依赖于通过 intent 传递的字符串数据的 NextActivity 类,以下哪段代码可以启动您的活动?

    Intent(this, NextActivity::class.java).also { intent ->
        startActivity(intent)
    }
    Intent(this, NextActivity::class.java).apply {
        put(EXTRA_NEXT, "some data")
    }.also { intent ->
        activityStart(intent)
    }
    Intent(this, NextActivity::class.java).apply {
        putExtra(EXTRA_NEXT, "some data")
    }.also { intent ->
        startActivity(intent)
    }
    Intent(this, NextActivity::class.java).apply {
        put(EXTRA_NEXT, "some data")
    }.also { intent ->
        activityStart(intent)
    }

Q8. 您想在项目中包含 about 和 settings 模块。以下哪个文件准确反映了它们的包含?

Q9. 使用 @VisibleForTesting 注解的好处是什么?

Q10. 如何在 build.gradle 文件中指定您的应用至少需要 API level 21 才能运行,但可以在 API level 28 上进行测试?

      defaultConfig {
        ...
        minApiVersion 21
        targetApiVersion 28
      }
      defaultConfig {
        ...
        targetSdkVersion 21
        testSdkVersion 28
      }
      defaultConfig {
        ...
        minSdkVersion 21
        testApiVersion 28
      }
      defaultConfig {
        ...
      minSdkVersion 21
        targetSdkVersion 28
      }

Q11. 什么时候会调用 activity 的 onActivityResult()?

Reference

Q12. 您需要根据 Event 的 ID 从 API 中删除一个 Event,以下哪段代码定义了 Retrofit 中的请求?

Q13. 什么时候会在构建设置中使用 product flavor?

Q14. 给定以下 fragment,如何访问 Fragment 类布局文件中 ID 为 text_home 的 TextView?

    private lateinit var textView: TextView
    override fun onCreateView(...): View? {
        val root = inflator.inflator(R>layout.fragment_home, container, false)
        textView = ??
        return root
    }

Q15. 为什么在运行 UI 测试时使用 AndroidJUnitRunner?

Notice: AndroidJUnitRunner lets us run JUnit3/4-style tests on Android Devices

Q16. 什么可以让您在 activity 重新启动时正确恢复用户状态?

Refrence

Q17. 如果主线程被阻塞太久,系统会显示 _ 对话框。

Q18. 如何从 SharedPreferences 中检索用户的 email 值并确保返回值不为 null?

Explanation: In Method "getDefaultSharedPrefarances(this).getString()" The Second parameter is passed so that it can be returned, in case the key doesn't exist. So we need to pass an empty string to be returned in case the key doesn't exist.

Q19. 为什么在 Android 中使用像素定义大小会有问题?

Reference

Q20. 您需要获取连接到计算机并启用了 USB debugging 的设备列表。使用 Android Debug Bridge 应执行哪个命令?

Q21. 哪种 drawable 定义可以实现以下形状?

img

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <stroke
            android:width="4dp"
	    android:color="@android:color/white" />
	<solid android:color="@android:color/black" />
    </shape>
    <oval xmlns:android="http://schemas.android.com/apk/res/android">
        <stroke android:width="4dp" android:color="@android:color/black"/>
        <solid android:color="@android:color/white"/>
    </oval>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <stroke
            android:width="4dp"
            android:color="@android:color/black" />
        <solid android:color="@android:color/white" />
    </shape>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <stroke
            android:width="4dp"
            android:color="@android:color/white" />
        <solid android:color="@android:color/white" />
    </shape>

Q22. 要持久化一小部分键值数据,应该使用什么?

Q23. 您需要从 API 中检索照片列表。以下哪段代码定义了 Retrofit 中的 HTML GET 请求?

Q24. 给定以下测试类,哪段代码是正确的断言?

Q25. 应使用哪个标签将可重用的视图组件添加到布局文件中?

Q26. 您希望为处于 landscape 模式且语言设置为法语的设备提供不同的 drawable,哪个目录命名正确?

Q27. 为什么需要在应用中包含以下权限?

android.permission.ACCESS_NETWORK_STATE

Q28. Jetpack Compose 的核心目标是什么?

Q29. 您的应用需要一些可能经常更新的数据。您不希望每次需要数据时都进行 API 调用。应该使用什么数据存储方法?

Q30. 如何在 ListView 中设置滚动监听器?

Q31. 您希望为包含 listview 的 RecyclerView 项添加 ripple 效果。以下哪项是正确的方法?

Q32. 您需要为 activity 提供用户位置。使用以下代码片段,您应该在哪里向用户请求位置权限?

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if(ContextCompat.checkSelfPermission(this,
        Manifest.permission.ACCESS_FINE_LOCATION)
        != PackageManager.PERMISSION_GRANTED){
        // A
    } else {
        // B
    }
}

Q33. 您创建了一个需要用户名、密码和服务器 URL 的类。应该如何获取这些值?

Q34. 您希望启用数据绑定以避免在 activity 中写出 findViewById()。应该采取以下哪种步骤?

Q35. Android Jetpack 是什么?

Q36. 应使用什么来添加视图?

Q37. ConstraintLayout 为什么有用?

Q38. 您希望确保 RecyclerView 的 RecyclerView.Adapter 在数据发生变化时在正确的时间有正确的可用数据。应该使用哪个 observer?

Q39. 您希望在 Kotlin 代码中初始化 ListView,但不希望它在其视图层次结构中监听 click events。应该如何使 ListView 实现此效果?

Q40. 应该使用什么为 image view 指定图像源?

Q41. 您创建了一个正在开发的功能分支,希望在测试时暂时增加 HTTP 连接超时时间。您应该如何进行这个更改?

Q42. 当运行设备的主题设置为深色时,您希望为应用提供自定义暗色主题。应该怎么做?

Q43. EditText 类的 inputType 属性是什么?

Q44. 您使用 API 21 创建了应用,以支持 Android 5.0(Lollipop)及更高版本,但 Google Play 商店显示您的应用只对 Android 7.0(API 24)及更高版本的设备可用。应该如何解决这个问题?

Q45. 测试必须是 _ ,以便它们可以独立于其他测试执行?

Q46. 根据 Google 的推荐,使用 Android KTX 开发时,应该使用哪种依赖项注入?

Q47. 您希望在测试时测试 GPS 功能,但需要在设备上模拟位置数据。应该使用什么来实现这一点?

Q48. onCreate() 是 Activity 生命周期中的第一个回调。在这个回调中应该完成什么任务?

Q49. 为什么字符串应该在 strings.xml 文件中定义而不是硬编码到应用的 activities 和 layouts 中?

Q50. 在 onCreate() 中可能执行的任务中,以下哪些选项应该推迟到 onResume() 中?

Q51. 您启动了应用,当检索数据时它崩溃了。应用启动到崩溃的时间太快,无法打开 Logcat。您可以使用哪个命令查看 Logcat 数据?

Q52. 为什么应该在开发时为您的应用使用 fragments?

Q53. 在 Kotlin 中,by lazy 属性应该用于什么?

Q54. 您已经有一个 Activity,并且您想通过点击按钮加载一个 Fragment。以下代码有什么作用?

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

	if (savedInstanceState != null) return

	val fragment = CreatePostFragment()
		supportFragmentManager
		.beginTransaction()
		.add(R.id. fragment_container, fragment)
		.commit()

}

Q55. 以下哪个组件不是系统或用户进入应用程序的入口点?

Q56. 应该使用什么来显示一个大型的可滚动元素列表?

Q57. 您创建了一个显示应用详细信息的 AboutActivity 类。以下哪段代码可以启动您的 activity?

Explanation: Intent(Context packageContext, Class<?> cls) Notice: Class not KClass

Q58. AndroidManifest.xml 文件的用途是什么?

Q59. 元素 的哪个属性用于指定应用程序运行所需的最低 API level?

Q60. 为了在发布版本中缩减代码,Android Studio 使用了什么工具?

Explanation: When you build your project using Android Gradle plugin 3.4.0 or higher, the plugin no longer uses ProGuard to perform compile-time code optimization. Instead, the plugin works with the R8 compiler.

Reference

Q61. 哪种布局层次结构可能绘制得最快?

Q62. 当前推荐的处理长时间运行的后台任务的方法是什么?

Q63. 您需要通过 Google Play 按需或作为即时体验向用户提供应用的某些功能。您应该创建哪种类型的模块?

  1. Reference
  2. Reference

Q64. 以下哪种方法不推荐用于在应用中提供有用的离线状态?

Reference

Q65. 如果您需要应用代码检查当前构建的信息,应该使用哪个类?

Q66. 在下面的 ConstraintLayout 中,为什么按钮不会扩展填满 parent 的宽度?

    <androidx.constraintlayout.widget.ConstrantLayout
        ...>
	    <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="Button"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"/>

    </androidx.constraintlayout.widget.ConstrantLayout>

Q67. 以下哪种情况不是在 Espresso 测试中使用 idling resources 的用途?

Q68. 以下哪种不是为应用提供字符串的资源类型?

Q69. 以下哪个不是 activity lifecycle 中的方法?

Q70. 您希望允许用户在应用中拍摄照片。以下哪个代码片段是正确的方法?

  fun showCamera(view: View) {
      Log.i(TAG, "Show camera button pressed.")
      if (ContextCompat.shouldShowRequestPermissionRationale(thisActivity,
      Manifest.permission.CAMERA) {
        showCameraPreview()
      }
       else {
         requestPermissionLauncher.launch(Manifest.permission.CAMERA)
       }
   }
  fun showCamera(view: View) {
      Log.i(TAG, "Show camera button pressed.")
      if (ContextCompat.checkSelfPermission(thisActivity,
      Manifest.permission.CAMERA)
      == PackageManager.PERMISSION_GRANTED) {
        showCameraPreview()
      }
      else {
         requestPermissionLauncher.launch(Manifest.permission.CAMERA)
      }
  }
  fun showCamera(view: View) {
      Log.i(TAG, "Show camera button pressed.")
      showCameraPreview()
  }
  fun showCamera(view: View) {
      Log.i(TAG, "Show camera button pressed.")
      if (ContextCompat.checkSelfPermission(thisActivity,
      Manifest.permission.CAMERA)
      != PackageManager.PERMISSION_GRANTED) {
         showCameraPreview()
       }
       else {
          requestPermissionLauncher.launch(Manifest.permission.CAMERA)
       }
  }

Q71. 给定以下字符串资源,哪个代码片段是有效的?

<string name="upload_photo_notification">%1$d of %2$d photos uploaded</string>
val string: String = getString(
   R.string.upload_photo_notification,
   "2",
   "5"
)
val string: String = getString(
   R.id.upload_photo_notification,
   2,
   5
)
val string: String = getString(
   R.string.upload_photo_notification,
   2,
   5
)
val string: String = getString(
   R.id.upload_photo_notification,
   "2",
   "5"
)

Reference

Q72. 不同语言对数量的语法规则不同。为了在应用中支持以下两个字符串,理想的资源定义是什么?

"You have 1 day remaining"
"You have 2 days remaining"
<string name="trial_days_left_one"> You have %1$d day remaining</string>
<string name="trial_days_left_other">You have %1$d days remaining</string>
<plurals name="trial days left">
    <plural quantity="one">You have %1$d day remaining</plural>
    <plural quantity="other">You have %1$d days remaining</plural>
</plurals>
<plurals name="trial_days_left">
    <item quantity="one">You have %1$d day remaining</item>
    <item quantity="other">You have %1$d days remaining</item>
</plurals>
<string name="trial_days_left">
    <plural quantity="one">You have %1$d day remaining</plural>
    <plural quantity="other">You have &1$d days remaining</plural>
</string>

Q73. 操作系统何时会使用 onTrimMemory() 方法?

Reference

Q74. 在您的应用中,有一个 RecyclerView 列表。您希望为 portrait 和 landscape 模式提供不同的配置。以下哪个代码片段最适合支持下面的布局?

img

recyclerView.setLayoutManager(GridLayoutManager(this, 3))
val coulumnCount = resources.getInteger(R.integer.column_count)
recyclerView.setLayoutManager(GridLayoutManager(this, columnCount))
recyclerView.setLayoutManager(LinearLayoutManager(this))
val coulumnCount = resources.getInteger(R.integer.column_count)
recyclerView.setLayoutManager(LinearLayoutManager(this, columnCount))

Q75. 您需要根据 Event 的 ID 从 API 中删除一个 Event。以下哪个代码片段定义了 Retrofit 中的请求?

Q76. 您希望允许用户在应用中拍摄照片。以下哪项不是创建适当 intent 而不是直接请求 camera permission 的优势?

Q77. 当前推荐的处理长时间运行后台任务的方法是什么?