title: Android - Install APK via intent - react to failure
body: <p>I am installing an APK via the following intent:</p>
  
  <pre><code>val apkUri = Uri.fromFile(apkFile)
  val intent = Intent(Intent.ACTION_VIEW)
  intent.setDataAndType(apkUri, "application/vnd.android.package-archive")
  intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
  context.startActivity(intent)
  </code></pre>
  
  <p>I know that I can retrieve the PACKAGE_ADDED broadcast and then react in case the APK was installed.
  However, how can I react if the installation failed? E.g. if the APK was not parsed correctly (e.g. if its for a different architecture) or simply if the user clicks "CANCEL" on the request?</p>
  
  <p>I also tried <code>startActivityForResult</code> and the corresponding <code>onActivityForResult</code> functions, but that seems to be independent on the user action and is immediately triggered when the intent was fired. </p>