首页 \ 问答 \ Android ==>应用程序开发?(Android ==> Application development?)

Android ==>应用程序开发?(Android ==> Application development?)

  1. 我是iphone应用程序开发人员,所有iphone都有非常相似的操作系统,大小和一切都是一样的,所以我不需要为每个iphone创建特定的应用程序。 但是对于Android有不同的手机,不同的尺寸,那么我怎么可能知道我的应用程序工作,并在所有这些设备上看起来很好

  2. 我还没有自己的Android,但我使用模拟器完成了我的第一个应用程序。 您建议哪种Android手机进行测试? 我是AT&T用户,我使用iphone。 我可以简单地在新的Android中插入我的SIM卡,以便能够在设备上测试我的应用程序吗?


  1. 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

  2. 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
更新时间:2023-09-22 10:09

最满意答案

将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的标准方法是扩展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 ...
  • 感谢Milan Baran在Shiro用户论坛上的回答。 github repo已经更新,如果有兴趣的话,这里有一个快速摘要: 在Bootstrap类中,我们只需要为/ *添加一个GuiceFilter,根本不需要默认服务器。 那么,那就变成了: public static void main(String[] args) throws Exception { Server server = new Server(8081); WebAppContext webAppContext = n ...
  • 截至黄瓜gu1 v1.2.4,这已略有变化。 首先配置文件已更改其名称,现在是cucumber.properties 。 其次,现在除了构建模块之外,还必须构建一个扩展了cucumber.runtime.java.guice.InjectorSource的类,并将其设置为属性文件中guice.injector-source的值。 所以除了你已经创建的两个类之外,你还需要创建第三个类: public class MyInjectorSource implements InjectorSource { ...

相关文章

更多

最新问答

更多
  • 以编程方式创建视频?(Create videos programmatically?)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • javascript数组,如何改变这个数组结构(javascript arrays, how to change this array structure)
  • 在ASP.NET Web API中使用多个Get方法进行路由(Routing with multiple Get methods in ASP.NET Web API)
  • 用于backbone.js验证的自定义验证器(Custom validator for backbone.js validation)
  • const char *与其他指针有什么不同?(Is const char * different from other pointers? [duplicate])
  • 无效的列索引,使用PreparedStatement更新(Invalid column index , update using PreparedStatement)
  • watchOS WCSession'已配对'和'watchAppAvailable'不可用(watchOS WCSession 'paired' and 'watchAppAvailable' are unavailable)
  • CalledFromWrongThreadException在Android上执行JUnit测试(CalledFromWrongThreadException exercising JUnit tests on Android)
  • 如何把文件保存到你的应用程序目录中?(How to put\save files into your application directory? (adobe air))
  • 美元符号在Java方法描述符中的含义?(Meanings of dollar sign in Java method descriptor?)
  • font-size的含义是什么:1em / 2em?(What doe the meaning of font-size:1em/2em?)
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • Android - 检测与特定wifi ssid断开连接的正确方法?(Android - Correct way to detect disconnecting from a particular wifi ssid?)
  • 通过Shell脚本将文件转换为另一个文件(Convert File To Another File By Shell Script)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • 如何过滤magento废弃的购物车报告集合(How to Filter the magento abandoned cart report collection)
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • web api http post传递对象504接收失败(web api http post passing object 504 Receive Failure)
  • Rails从视图编辑模型上的多个属性的方法(Rails way to edit multiple attributes on a model from a view)
  • 总是用{}初始化对象是否是好习惯?(Is it good habit to always initialize objects with {}?)
  • 在方案中编写特殊字符到输出端口(编译器设计)(writing special characters to output port in scheme (compiler design))
  • 电脑等级考试得证有多大用处?
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • 第一次调用函数将无法按预期工作,但下一次工作正常(calling a function on the first time won't work as expected, but next time is working)
  • 如何优化使用BigInteger操作执行时间的代码(How to optimize the code that uses BigInteger operations for execution time)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何提供个人资料信息,以便Passport.js可以使用它?(how does Profile information should be provided so Passport.js can use it?)
  • 有没有办法初始化jquery数据表中的细节?(is there any way to initialize details in jquery datatable?)