There is an application in the resources in the raw folder called bochs.apk and it needs to be installed from the application.


It does not go out to install (I tried a lot of options with enSO , etc.), the last installation option:

 mContext.startActivity(new Intent(Intent.ACTION_VIEW).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setDataAndType( Uri.parse("android.resource://" + mContext.getPackageName() + "/" + R.raw.bochs), "application/vnd.android.package-archive")); 

To which I get an error:

 01-26 20:25:30.975 4584-4584/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.rostislav.dugin.osloader, PID: 4584 android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=android.resource://com.rostislav.dugin.osloader/2131165184 typ=application/vnd.android.package-archive flg=0x10000000 } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1792) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512) at android.app.ContextImpl.startActivity(ContextImpl.java:1364) at android.app.ContextImpl.startActivity(ContextImpl.java:1338) at android.content.ContextWrapper.startActivity(ContextWrapper.java:323) at com.rostislav.dugin.osloader.ui.presenter.SettingsPresenter.onInstallBochsClick(SettingsPresenter.java:94) at com.rostislav.dugin.osloader.ui.view.fragments.SettingsFragment.lambda$setUpViews$3(SettingsFragment.java:117) at com.rostislav.dugin.osloader.ui.view.fragments.SettingsFragment$$Lambda$3.onClick(Unknown Source) at android.view.View.performClick(View.java:4848) at android.view.View$PerformClick.run(View.java:20260) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5624) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) 

What am I doing wrong and how to fix it?

  • Fluent Google says that this will not work and you must first write the file to the thread from the resources and only then install it - YuriiSPb
  • @Yuriy SPb, hmm ... Unpack the Android/data/мой_пакет/temp and then install it? - user189127
  • one
    I'm not sure what exactly this path is, but, yes, in any directory accessible to the application. - tse

0