- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Android 应用程序可以创建本地 HTML 文件,然后在浏览器中将其显示给用户。我遇到过 BrowserActivity 无法在不同设备上运行的问题,具体取决于安装的浏览器。我当前的代码执行以下操作 -
public void displayStats()
{
String file = produceStats();
Uri uri = Uri.parse("file://" + file);
// chrome ??
Intent intent1 = new Intent(Intent.ACTION_VIEW);
intent1.setDataAndType(uri, "multipart/related");
// default "Internet" browser
Intent intent2 = new Intent(Intent.ACTION_VIEW, uri);
intent2.setDataAndType(uri, "text/html");
intent2.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
// any other browser (FireFox) ??
Intent intent3 = new Intent(Intent.ACTION_VIEW);
intent3.setDataAndType(uri, "text/html");
intent3.addCategory(Intent.CATEGORY_BROWSABLE);
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities1 = packageManager.queryIntentActivities(intent1, 0);
List<ResolveInfo> activities2 = packageManager.queryIntentActivities(intent2, 0);
List<ResolveInfo> activities3 = packageManager.queryIntentActivities(intent3, 0);
boolean isIntentSafe1 = activities1.size() > 0;
boolean isIntentSafe2 = activities2.size() > 0;
boolean isIntentSafe3 = activities3.size() > 0;
List<Intent> targetedShareIntents = new ArrayList<Intent>();
if (isIntentSafe1)
{
unpackResolvedIntents(uri, "multipart/related", activities1, targetedShareIntents);
}
if (isIntentSafe2) {
unpackResolvedIntents(uri, "text/html", activities2, targetedShareIntents);
}
if (isIntentSafe3) {
unpackResolvedIntents(uri, "text/html", activities3, targetedShareIntents);
}
if (targetedShareIntents.isEmpty()) {
// go to market to install app ????
Toast.makeText(plink.this, "Please install BROWSER to complete (Chrome)", Toast.LENGTH_LONG).show();
Intent goToMarket = new Intent(Intent.ACTION_VIEW)
.setData(Uri.parse("market://details?id=com.android.chrome"));
startActivity(goToMarket);
} else if (targetedShareIntents.size() == 1) {
startActivity(targetedShareIntents.remove(0));
} else {
Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Select viewer");
Intent[] extraIntents = new Intent[targetedShareIntents.size()];
for (int i = 0; i < targetedShareIntents.size(); i++) {extraIntents[i] = targetedShareIntents.get(i);}
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents);
startActivity(chooserIntent);
}
}
produceStats() 调用返回文件路径,然后此函数的其余部分处理各种不同的浏览器,如果有多个可用浏览器,它会为用户提供一个选择器。
我的问题是,一位用户报告说,当他在装有 SILK 浏览器的 Kindle HD 设备上运行该应用程序时,应用程序崩溃了。因此,他的堆栈转储是 -
26 Jan 2014 16:26:09 GMT:Uncaught exception in java.lang.Thread:main(Unable to find explicit activity class {com.android.browser/com.android.browser.BrowserActivity}; have you declared this activity in your AndroidManifest.xml?)
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.browser/com.android.browser.BrowserActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1624)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1418)
我的问题是 - 如何在 Kindle 上启动以在 SILK 中显示文件?谢谢
最佳答案
基于对其 list 的检查,Kindle Fire HD 上的 Slik 似乎不支持 HTML 的 file://
方案。它似乎只支持 http://
、https://
和 inline://
。我无法解释您遇到的具体崩溃,因为我没有看到 AOSP 浏览器应用程序的任何迹象,所以我不知道为什么 PackageManager
会以其他方式报告。
关于Kindle HD 上的 Android BrowserActivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21414492/
我正在制作一个带有 "default_popup":"popup.html" 的 Chrome 扩展。 chrome.browserAction.onClicked 的文档说: Fired when
我正在学习如何编写 chrome 扩展,我发现一个例子,使用 browseraction 可以更改网页的背景颜色,我正在尝试做一些非常相似的事情,更改背景图像,但出于某种原因...它不起作用,js 函
我正在尝试添加一个数字,当您将鼠标悬停在 chrome 扩展图标上时,该数字将显示,并且该数字将随着脚本运行而改变。但是,当我添加 chrome.browserAction.setTitle({
我想制作一个 Chrome 插件,它可以显示 Facebook 图片。我的例如是 this one . 我确实得到了最终的 Url 和 XMLHttpRequest 的响应。 在response.re
文档说我们只能有 browserAction 或 pageAction 而不是两者。这有什么诀窍吗?或者作为解决方案,使用内容脚本并在页面中插入按钮是个好主意吗? 最佳答案 在 Chrome 的 ch
我有一个 Android 应用程序可以创建本地 HTML 文件,然后在浏览器中将其显示给用户。我遇到过 BrowserActivity 无法在不同设备上运行的问题,具体取决于安装的浏览器。我当前的代码
我知道使用以下内容将在我的 Google Chrome 扩展程序上加载带背景的文本,并将其 chop 为前四个字母。 chrome.browserAction.setBadgeBackgroundCo
我正在构建一个 chrome 扩展,其中添加 chrome.browserAction.onClicked.addListener(functioncallback) 监听器,但我一次只需要保留一个监
我正在制作一个 chrome 扩展程序,该扩展程序有两种模式:始终打开 (alwaysOn),或者仅当用户单击它时 (onClick)。我想根据用户的模式将图标更改为蓝色或红色,以便他们一眼就能看到。
我的扩展程序使用 tab.url 获取数据并将其放入 chrome.browserAction.setBadgeText。当我打开一个新标签时,它会重置。如何仅为新标签更新 BadgeText?并为旧
我想触发点击,下面的代码正在监听: chrome.browserAction.onClicked.addListener(function(tab) {}); 原因是我有一个工作扩展,它在后台脚本(上
我的 Chrome 扩展程序中的 browserAction 需要大约 250 毫秒才能显示其弹出窗口,popup.html .然而,当 popup.html已经在浏览器的选项卡中打开,然后 brow
我正在编写一个 Chrome 扩展程序,它会根据当前 URL 动态更改弹出窗口的内容。 我在 background.js 中做这样的事情,效果很好: if(domains.contains(reque
我们开发了一个 Chrome 扩展程序,我想在用户单击我们的图标时打开一个新选项卡。但问题是,我不知道我之前是否已经添加了这个事件监听器,以及它的有效期是多长时间。我尝试使用 chrome.brows
我想单击扩展程序的浏览器操作,然后在滚动之前加载 iframe。window.addeventlistener("load",scroll, false); 似乎是现在的问题。 我知道内容脚本将使 w
我正在为我的网站制作一个专用扩展程序,我想知道是否可以让该扩展程序仅响应我网站上的特定按钮单击。我希望能够在用户单击页面上的捕获按钮时执行 captureVisibleTab。 最佳答案 概述 注入(
我的问题相当简单,我只是想找出最简单的方法来做到这一点。 我的 Chrome 扩展程序的当前迭代通过一个按钮将 DIV 注入(inject)网页,按下该按钮时将执行一个功能。 我想在不注入(injec
我喜欢在 Chrome 扩展中切换 browserAction,它应该独立于选项卡 这是代码 Manifest.json { "name": "Toggle", "
我正在创建一个 chrome 扩展,但是我的 browser action不工作。 我的 list .jason { "name": "TypoSaurus", "version":
I'm looking at the documentation page我不知道我的代码有什么问题: chrome.browserAction.setIcon({ details.imageDa
我是一名优秀的程序员,十分优秀!