Android ==>应用程序开发?(Android ==> Application development?)
我是iphone应用程序开发人员,所有iphone都有非常相似的操作系统,大小和一切都是一样的,所以我不需要为每个iphone创建特定的应用程序。 但是对于Android有不同的手机,不同的尺寸,那么我怎么可能知道我的应用程序工作,并在所有这些设备上看起来很好
我还没有自己的Android,但我使用模拟器完成了我的第一个应用程序。 您建议哪种Android手机进行测试? 我是AT&T用户,我使用iphone。 我可以简单地在新的Android中插入我的SIM卡,以便能够在设备上测试我的应用程序吗?
I am an iphone application developer, all iphones have very similar Operating systems, and the size and everything is the same, so I don't need to create applications specific for each iphone. But with android there are different phones, different sizes, So How can I possibly know that my app works, and looks fine on all these devices
I don't already own an android but I completed my first application using the simulator. Which android phone do u suggest for testing? I am an AT&T user and Iuse an iphone. Can I simply insert my sim-card in the new android to be able to test my app on the device?
原文:https://stackoverflow.com/questions/3115724
最满意答案
将MetricsServlet添加到它自己的ServletContextHandler中,并注册MetricsServlet.ContextListener的实现来修复它。
_server = new Server(_port); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setDirectoriesListed(true); resourceHandler.setWelcomeFiles(new String[]{"index.html"}); resourceHandler.setResourceBase("."); HandlerList handlers = new HandlerList(); ServletContextHandler guiceHandler = new ServletContextHandler(); ServletContextHandler metricsContextHandler = new ServletContextHandler(); metricsContextHandler.setContextPath("/one/metrics"); metricsContextHandler.addEventListener(new MyMetricsServletContextListener(_metricRegistry)); metricsContextHandler.addServlet(MetricsServlet.class, "/registry"); guiceHandler.setContextPath("/one/id"); try { FilterHolder guiceFilter = new FilterHolder(_filter); guiceHandler.addFilter(guiceFilter, "/*", EnumSet.allOf(DispatcherType.class)); handlers.setHandlers(new Handler[]{metricsContextHandler, guiceHandler, resourceHandler}); _server.setHandler(handlers); _server.setDumpAfterStart(true); _server.start(); }catch(Exception ex) { log.error("Error starting http server", ex); throw new RuntimeException(ex); }
MetricsServlet.ContextListener实现(注册表通过guice绑定提供):
private static class MyMetricsServletContextListener extends MetricsServlet.ContextListener { private MetricRegistry _metricRegistry; public MyMetricsServletContextListener(MetricRegistry metricRegistry) { _metricRegistry = metricRegistry; } @Override protected MetricRegistry getMetricRegistry() { return _metricRegistry; } }
Adding the MetricsServlet to it's own ServletContextHandler, and registering an implementation of MetricsServlet.ContextListener fixed it.
_server = new Server(_port); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setDirectoriesListed(true); resourceHandler.setWelcomeFiles(new String[]{"index.html"}); resourceHandler.setResourceBase("."); HandlerList handlers = new HandlerList(); ServletContextHandler guiceHandler = new ServletContextHandler(); ServletContextHandler metricsContextHandler = new ServletContextHandler(); metricsContextHandler.setContextPath("/one/metrics"); metricsContextHandler.addEventListener(new MyMetricsServletContextListener(_metricRegistry)); metricsContextHandler.addServlet(MetricsServlet.class, "/registry"); guiceHandler.setContextPath("/one/id"); try { FilterHolder guiceFilter = new FilterHolder(_filter); guiceHandler.addFilter(guiceFilter, "/*", EnumSet.allOf(DispatcherType.class)); handlers.setHandlers(new Handler[]{metricsContextHandler, guiceHandler, resourceHandler}); _server.setHandler(handlers); _server.setDumpAfterStart(true); _server.start(); }catch(Exception ex) { log.error("Error starting http server", ex); throw new RuntimeException(ex); }
The MetricsServlet.ContextListener implementation (registry is provided via guice binding):
private static class MyMetricsServletContextListener extends MetricsServlet.ContextListener { private MetricRegistry _metricRegistry; public MyMetricsServletContextListener(MetricRegistry metricRegistry) { _metricRegistry = metricRegistry; } @Override protected MetricRegistry getMetricRegistry() { return _metricRegistry; } }
相关问答
更多-
事实证明,请求格式错误,但它没有返回任何错误或抛出异常。 请求将超时。 修复此问题的更改是在请求字符串中添加一个额外的换行符,以使服务器知道不要求请求中有更多数据。 response = _connector.getResponses("GET /ctx/rest/users HTTP/1.0\r\n\r\n"); ^ Turns out the request was ...
-
在没有ServletContext的情况下使用Guice配置Shiro(Configuring Shiro with Guice without a ServletContext)[2023-06-10]
获取ServletContext的标准方法是扩展GuiceServletContextListener 。 Imho是API的主要监督。 http://code.google.com/p/google-guice/issues/detail?id=603 这里还有一个教程: https://issues.apache.org/jira/browse/SHIRO-320 (编辑:阅读评论后)您有2个选项: 将代码重构为仅在GuiceServletContextListener创建注入器 使用儿童注射器(棘手) ... -
我发现了这个问题 ,他提到的解决方法有效。 基本上,我在其他地方调用了PersistService.start() ,而不是使用默认的PersistFilter,我使用了一个捕获IllegalStateException的自定义的。 I found this question, and the workaround he mentioned worked. Basically, I called PersistService.start() elsewhere, and instead of using t ...
-
我自己找到了答案 - 这有点令人尴尬。 问题是有两个日志记录配置文件:logback.xml和logback-test.xml。 我没有调整在maven项目开发过程中使用的logback-test.xml中的记录器级别。 另一方面,logback.xml配置在构建包时使用,例如在生产中使用。 从logback文档 : 如果您正在使用Maven,并且将logback-test.xml放在src / test / resources文件夹下,Maven将确保它不会包含在生成的工件中。 因此,您可以使用其他配置文 ...
-
将MetricsServlet添加到它自己的ServletContextHandler中,并注册MetricsServlet.ContextListener的实现来修复它。 _server = new Server(_port); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setDirectoriesListed(true); resourceHandler.setWelco ...
-
这已在此之前得到解答。 它已经有几年了,但应该帮助你。 此外,我将重新添加的9.4.x文档中意外删除了一个页面,但您现在可以在9.3.x文档中找到 。 这些食谱示例也应该有所帮助,但现在它们已经有几年了。 This has been answered before here. It is a few years old but should help you on your way. Additionally a page was accidentally clipped from the 9.4.x do ...
-
好吧,所以对我来说,事实证明它比我想象的还要容易。 只需通过以下示例代码指示Restlet提供一些静态内容即可: Directory directory = new Directory(getContext(), "file:///user/data/files/"); Router router = new Router(getContext()); router.attach("/static/", directory); 这不完全回答我的问题,但它解决了我的问题。 由于没有更多的答案,我正在关闭这个 ...
-
AbstractModule是Guice的bootstrap(配置)阶段的基本构建块。 你总是需要一个或多个。 另一方面, ServletModule是一种特殊化,它为您提供了一些配置,因为它在servlet容器中运行。 来自Guice文档 : 此模块设置请求和会话范围,并提供从中配置过滤器和servlet的位置。 关于Guice-Jersey集成,您当然需要进行设置。 它不会突然发挥作用。 Guice和任何其他依赖注入框架一样,在它可以控制构建对象时起作用。 如有疑问,请问自己是谁创造了这个对象。 使用J ...
-
使用Jersey-Guice-Shiro堆栈时,Jetty找不到login.jsp(Jetty can't find login.jsp when using Jersey-Guice-Shiro stack)[2022-04-02]
感谢Milan Baran在Shiro用户论坛上的回答。 github repo已经更新,如果有兴趣的话,这里有一个快速摘要: 在Bootstrap类中,我们只需要为/ *添加一个GuiceFilter,根本不需要默认服务器。 那么,那就变成了: public static void main(String[] args) throws Exception { Server server = new Server(8081); WebAppContext webAppContext = n ... -
配置黄瓜 - guice(Configuring cucumber-guice)[2022-04-22]
截至黄瓜gu1 v1.2.4,这已略有变化。 首先配置文件已更改其名称,现在是cucumber.properties 。 其次,现在除了构建模块之外,还必须构建一个扩展了cucumber.runtime.java.guice.InjectorSource的类,并将其设置为属性文件中guice.injector-source的值。 所以除了你已经创建的两个类之外,你还需要创建第三个类: public class MyInjectorSource implements InjectorSource { ...