相关疑难解决方法(0)

android.os.FileUriExposedException:file:///storage/emulated/0/test.txt通过Intent.getData()暴露在app之外

当我尝试打开文件时,应用程序崩溃了.它可以在Android Nougat下运行,但在Android Nougat上它会崩溃.当我尝试从SD卡打开文件而不是从系统分区打开文件时,它只会崩溃.一些许可问题?

示例代码:

File file = new File("/storage/emulated/0/test.txt");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "text/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent); // Crashes on this line
Run Code Online (Sandbox Code Playgroud)

日志:

android.os.FileUriExposedException:file:///storage/emulated/0/test.txt通过Intent.getData()暴露在app之外

编辑:

在定位Android Nougat时,file://不再允许使用URI.我们应该使用content://URI代替.但是,我的应用程序需要打开根目录中的文件.有任何想法吗?

android android-file android-7.0-nougat

682
推荐指数
15
解决办法
38万
查看次数

如何在android中实现更改日志?

对于我的应用程序,我想实现更改日志,但不知道如何(哪个概念).

我想,安装新版本的应用程序后,更新日志会弹出一次.听起来很简单,但我不知道.:/

显示我的更改日志的对话框已经存在,我只想知道如何在更新后显示它.

谢谢你的提示.

Prexx

android changelog

11
推荐指数
2
解决办法
5064
查看次数

使用targetSdkVersion 24进行Webview时出错

我的应用程序有一个WebView加载一个简单的HTML页面,其中包含一个iFrame,用于从合作伙伴公司加载支付流程的URL(我无权访问该URL源).

当我指向targetSdkVersion19时一切正常,我可以通过iFrame付款.但是,当targetSdkVersion指向24时我没有同样的运气.

在这种情况下,WebView管理加载iFrame,其中显示一些EditText用于输入信用卡信息和a Button提交它,但是当我点击该按钮时我总是有错误500.

由于付款URL是外包的,我到达了我们的合作伙伴公司,以便从500错误中了解origem.他们告诉我错误来自双重调用,这让我觉得WebView来自api 24的东西正在这样做.

500错误的打印: 在此输入图像描述

HTML文件payment_html如下:

<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    </head>

    <body id="bodyContent" onload="addListener()" style="margin:0px;padding:0px;overflow:hidden;height:355px">
        <iframe id="ifrPagamento" src="partner_url"
            frameborder="0" style="overflow:hidden;width:100%;height:100%"></iframe>
    </body>

    <script type="text/javascript">

        function addListener() {
            window.addEventListener("message", receiveMessage, false);
        }

        function receiveMessage(message) {

            if (message) {

                var data = JSON.parse(message.data);

                if (data.code) {

                    if(data.code === "0") {
                        app.returnStatus(0);
                    }
                    else {
                        app.returnStatus(1);
                    }
                }

            }

        }

    </script> …
Run Code Online (Sandbox Code Playgroud)

iframe android webview android-webview

10
推荐指数
1
解决办法
1130
查看次数