title: How to display random data from ArrayList in Kotlin?
body: <p>I have a list of apps installed on the device. Now I want to show a list of 10-20 (the number of applications should always be different) random applications, how can I do this in Kotlin?</p>
  <p>My code:</p>
  <pre><code>private fun onGetApps() {
          val pm: PackageManager = requireContext().packageManager
          val apps: List&lt;PackageInfo&gt; = requireContext().packageManager.getInstalledPackages(PackageManager.GET_META_DATA)
          val res: ArrayList&lt;Apps&gt; = ArrayList&lt;Apps&gt;()
  
          for (i in apps.indices) {
  
              if (pm.getLaunchIntentForPackage (apps[i].packageName) != null)
              {
                  val p = apps[i]
  
                  val appInfo = Apps()
  
                  appInfo.appName = p.applicationInfo.loadLabel(requireContext().packageManager).toString()
                  appInfo.appImage = p.applicationInfo.loadIcon(requireContext().packageManager)
                  res.add(appInfo)
              }
  
              mAdapter.setupApps(res)
              mAdapter.notifyDataSetChanged()
          }
      }
  </code></pre>