在Android WebView中处理国际化/本地化的最佳方法是什么?理想情况下,我想访问以下所有字符串资源:
res/values/strings.xml res/values-de/strings.xml ...
有没有人以有效的方式做到这一点?
Android本地化信息:http: //developer.android.com/guide/topics/resources/localization.html
最好的, - 托马斯阿姆斯勒
是否有任何关于 WebView JavaScript Bridge 的文档?我正在寻找描述“JavascriptInterface”中定义的方法的功能和支持的数据类型的文档。
例如,如果我定义以下内容:
public class JavaScriptInterface {
public int incrementNumber(int num) {
return num + 1;
}
Run Code Online (Sandbox Code Playgroud)
如果我从 JavaScript 中调用此方法并在模拟器中运行它,一切似乎都正常。如果我在 NexusOne 上运行它,传入的“num”参数始终为“0”。
如果我将上述更改为:
public class JavaScriptInterface {
public int incrementNumber(String num) {
// Leaving out try/catch
int tempNum = newRadius = Integer.parseInt(num);
return tempNum + 1;
}
Run Code Online (Sandbox Code Playgroud)
......一切似乎都有效。所以我想知道 JavaScriptInterface 方法参数是否应该/只能是 String 类型?
相关资源:http : //developer.android.com/reference/android/webkit/WebView.html http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object, java.lang.String) http://code.google.com/apis/maps/articles/android_v3.html
我需要访问WebView中的进度值 - > WebChromeClient - > onProgressChanged().进度整数值不会从0增加到100,而是跳转.以下是加载一个页面的示例日志输出和相关的进度编号:
DEBUG: progress : 10
DEBUG: progress : 100
DEBUG: progress : 10
DEBUG: progress : 100
DEBUG: progress : 10
DEBUG: progress : 100
DEBUG: progress : 10
DEBUG: progress : 10
DEBUG: progress : 100
DEBUG: progress : 10
DEBUG: progress : 100
DEBUG: progress : 10
DEBUG: progress : 100
DEBUG: progress : 10
DEBUG: progress : 100
DEBUG: progress : 10
DEBUG: progress : 30
DEBUG: progress : 100
DEBUG: …Run Code Online (Sandbox Code Playgroud) 我的Android应用程序使用HttpClient/HttpGet来访问REST API.我还设置:
httpGet.addHeader("Authorization", "Basic " + basicAuth);
Run Code Online (Sandbox Code Playgroud)
...将Base64编码的"用户名:密码"发送到服务器.为了测试,我只使用HTTP而不是HTTPS连接到服务器.
每当我在HttpClient上调用"execute"时,我都会收到以下异常:
07-28 10:51:39.610: I/# PA #(12112): org.apache.http.NoHttpResponseException: The target server failed to respond
07-28 10:51:39.610: I/# PA #(12112): at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:85)
07-28 10:51:39.610: I/# PA #(12112): at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:174)
07-28 10:51:39.610: I/# PA #(12112): at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:180)
07-28 10:51:39.610: I/# PA #(12112): at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235)
07-28 10:51:39.610: I/# PA #(12112): at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259)
07-28 10:51:39.610: I/# PA #(12112): at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
07-28 10:51:39.610: I/# PA #(12112): at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
07-28 10:51:39.610: I/# PA #(12112): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:428)
07-28 10:51:39.610: I/# …Run Code Online (Sandbox Code Playgroud) 我正在尝试配置特定于环境的 Lambda 函数的 S3 策略存储桶。我希望能够在指定“dev”、“test”或“prod”的“sam package”或“sam deploy”期间传递变量。该变量将在 template.yaml 文件中用于选择特定于环境的设置:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
image-processing
Resources:
ImageProcessingFunction:
Type: AWS::Serverless::Function
Properties:
Handler: src/handlers/image-processing.handler
Runtime: nodejs12.x
CodeUri: .
MemorySize: 256
Timeout: 300
Policies:
S3CrudPolicy:
BucketName: dev-bucket-name <-- change this to dev, test or prod
Run Code Online (Sandbox Code Playgroud)
如何使用参数和/或变量来实现这一点?谢谢你。
在模拟器上运行时,应用程序不会从HTTPS URL加载图像.
示例代码:
URL url = new URL("https://someserver.com/photo.jpg");
mImageView.setImageBitmap(BitmapFactory.decodeStream(url.openStream()));
Run Code Online (Sandbox Code Playgroud)
在实际设备上运行时,图像加载正常.如果通过HTTP而不是HTTPS访问图像,模拟器也会加载图像.
我做错了什么或这是一个已知的问题?