Stop Android from displaying "Install blocked" prompt


Question

I am continually getting prompts for installing apps, such as Clean Master and or 9 apps on my Android phone. I turned off the option "Install apps from unknown sources" in security settings but then a message would popup saying "Install blocked" every time, as shown in the screenshot below.



So, how to stop these annoying prompts?



(Click image to enlarge)



message showing install blocked


Answer

You're better off with Izzy's advise and find and weed out the app trying to install that Clean Master app. Anyhow, there you go with an another solution.


When you attempt to sideload an apk using UI or any app that attempts to install an apk and isn't granted the permission android.permission.INSTALL_PACKAGES, Package Installer app comes into action and its activity PackageInstallerActivity is launched. The setting for unknown sources (install_non_market_apps) under Settings Storage's database is checked and based on that, you're either shown that prompt (dialog) or the permissions and the install button.


Even if you manage to find a hack that disables that prompt from being shown, Package Installer would still be launched and the UI would look awkward since only app's label and white space would be visible to you, which would do naught but create confusion.


For rooted Android


The solution I ended up with is to get rid of the activity PackageInstallerActivity. You can use Elixir 2 to disable that activity.


Launch it → Application → tap IMG: → System applications → Package Installer → find and disable the said activity


You can also use in this case


adb shell su -c pm disable com.android.packageinstaller/.PackageInstallerActivity # Disables the activity
adb shell su -c pm enable com.android.packageinstaller/.PackageInstallerActivity # Use it to enable the activity

Now whenever you or an app attempt to sideload an apk which requires launching the Package Installer app, you may either get a toast like in the following image or an app registered to open/explore an apk would be launched or be suggested by system.


(Click image to enlarge)


IMG:


If the toast becomes noisy, hide it using EnhancedToast1 or UnToaster2. Since they are Xposed modules, you would need Xposed Framework appropriate3 for your Android version.


Note that disabling that activity wouldn't affect the ability of Play Store to install an app, neither would it affect adb install because the underlying package manager is intact.


You can use here too. Example, whenever your preferred file manager is active on screen, enable that activity so that you can continue to sideload an apk, should you decide to, and keep it disabled for any other on-screen active app.


For non-rooted Android


You (KitKat or Lollipop users) can hide/block the whole Package Installer app. You definitely need for that.


adb shell pm block com.android.packageinstaller # for KitKat 
adb shell pm hide com.android.packageinstaller # for Lollipop

The biggest inconvenience here is that you won't be able to uninstall an app using Settings app because it uses Package Installer's activity named UninstallerActivity and UninstallAppProgress. Attempt to removal of an app using Settings app would cause the latter to crash.


Every time you intend to remove an app using Settings app or sideload an apk using UI, you must unhide/unblock Package Installer app.


To unblock/unhide, do


adb shell pm unblock com.android.packageinstaller # for KitKat 
adb shell pm unhide com.android.packageinstaller # for Lollipop

Note that hiding/blocking that app wouldn't affect the ability of Play Store to install an app, neither would it affect adb install because the underlying package manager is intact.




1: XDA: EnhancedToast

2: XDA: UnToaster

3. Xposed Framework: Android 4.x, Android 5.x and 6.x


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes