小编Ali*_*and的帖子

蓝牙LE扫描滤镜无法正常工作

我想在我的Android代码中仅扫描具有特定UUID的BLE信标.即使我可以为特定的MAC地址添加过滤器,但我无法使其与UUID一起使用.永远不会调用onScanResult函数.为什么会这样?我正在使用API​​ 21,我没有收到任何项目错误.

final String tagUUID = "01122334-4556-6778-899a-abbccddeeff0";

//does not work
ScanFilter filter = new ScanFilter.Builder().setServiceUuid(new ParcelUuid(UUID.fromString(tagUUID))).build();

//works
ScanFilter filter = new ScanFilter.Builder().setDeviceAddress(tagMAC).build();
Run Code Online (Sandbox Code Playgroud)

android bluetooth-lowenergy

8
推荐指数
2
解决办法
6563
查看次数

如何在Android上的WebView中读取Blob中的数据?

我有一个服务器在浏览器上创建一个对象blob,我想在Android应用程序的WebView中下载它.我尝试将请求重定向到浏览器实例以及使用下载管理器执行此操作,但它们似乎都不起作用(即使我在Chrome中打开相同的页面,下载操作也在那里工作).

我尝试了以下代码,它抛出错误:

Android.content.ActivityNotFoundException:找不到处理Intent的活动{act = android.intent.action.VIEW dat = blob:https%3A // 111.111.111.111%3A8080/40b63131-63b1-4fa4-9451-c6297bbd111a"

编辑

Android.content.ActivityNotFoundException:找不到处理Intent的Activity {act = android.intent.action.VIEW dat = blob:http://digitalinsensu.com/0f0d6127-a0f1-44c3-af85-72f648258d6d


码:

mWebView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,String contentDisposition, String mimetype,long contentLength) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    startActivity(i);
}
});
Run Code Online (Sandbox Code Playgroud)

这会抛出java.lang.IllegalArgumentException:只能下载HTTP/HTTPS URIs错误:

mWebView.setDownloadListener(new DownloadListener() {
    public void onDownloadStart(String url, String userAgent,String contentDisposition, String mimetype,long contentLength) {
        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
        request.allowScanningByMediaScanner();
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "download");
        DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
        dm.enqueue(request);

    }
});
Run Code Online (Sandbox Code Playgroud)

我该如何下载blob?任何帮助,将不胜感激.

android blob android-webview

6
推荐指数
2
解决办法
8083
查看次数