Android - 服务 View

标签 android service view installation overlay

我正在使用覆盖大部分屏幕的叠加 View 。但是,我收到了用户报告说他们在安装第三方 APK 时无法按下包管理器的安装按钮。

有什么办法可以解决这个问题吗?我考虑过使用 BroadcastReceiver 来捕获 ACTION_VIEW Intent ,但这似乎是不可能的,因为这是一个 Activity 操作

我留下我的类和xml布局文件以供引用:

public class OverlayView extends RelativeLayout{

    private ImageView mImageView;

    public OverlayView(ServiceOverlay overlayService) {
        super(overlayService);
        load();
        mImageView = (ImageView) findViewById(R.id.backgroundimg);
    }



    public void destroy() {
        final WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
        wm.removeView(this);
    }

    private void load() {
        LayoutInflater.from(getContext()).inflate(R.layout.overlay, this);
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                0x50728,
                -3);
        params.gravity = Gravity.CENTER;
        ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).addView(this, params);
    }    
}

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" 
    android:paddingTop="0.0dip"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_margin="0.0dip"
    android:adjustViewBounds="false"
    android:windowActionBarOverlay="true"
      xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageView android:id="@+id/backgroundimg"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/bg2"
        android:dither="false"
        android:scaleType="fitXY"
        android:windowActionBarOverlay="true" />
</LinearLayout>

最佳答案

应用程序安装始终由用户控制。这就是它的设计方式,也应该如此。

例如,想象一下如果用户无法控制设备上安装的应用程序会发生什么。将安装各种垃圾应用程序,用户将失去对设备的控制。这有时可能会影响设备的通话、消息传递和整体效率。

因此,用户需要从设备设置中删除此功能,以便能够通过 APK 安装第三方未签名的应用程序,因为这些应用程序尚未发布到 Google Play。

关于Android - 服务 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29828317/

相关文章:

Android FPS,如何让它更流畅?

android - 在 Flutter 应用程序中创建自定义文本选择操作

java - Android 中的 "general"函数应该放在哪里?

android - 在android中没有NotificationListenerService的情况下读取通知

cakephp 并创建一个移动网站

android - 在代码中将 View 添加到现有的 xml View 组

android - 7天后自动卸载Android App

android - 如何在停止时再次启动相同的音频

Android @RestService 通过 androidannotations 注入(inject)导致 nullPointerException

android - GridView getChildAt() 返回 null