位置管理器无法在Android 4.0.2模拟器中运行

我在我的应用程序中使用Location Manager进行GPS跟踪。 在Android 2.2,2.3.3模拟器和设备中使用时,应用程序返回apt位置。 但是,奇怪的是我在模拟器4.0.2中测试了应用程序。 它返回强制关闭错误,如05-28 15:13:46.584: E/AndroidRuntime(4458): at com.package.TestRun.registerLocationListeners(TestRun.java:191)在logcat中的 05-28 15:13:46.584: E/AndroidRuntime(4458): at com.package.TestRun.registerLocationListeners(TestRun.java:191) 。 我已经实现了如下代码: LocationManager lm; LocationManager lmNet; private void registerLocationListeners() { lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (myGPSLocationListener == null || mynetworkprovider == null) { createLocationListeners(); } lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER ,0,0,mynetworkprovider); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER ,60000,0,myGPSLocationListener); } private void createLocationListeners() { mynetworkprovider = new LocationListener() { public […]

使用gradle对带有嵌入式玻璃鱼的jar进行容器测试失败

我正在使用JUnit和嵌入式glassfish来使用CDI测试一些代码。 这似乎相当简单但我必须遗漏一些东西。 我创建了一个简单的项目来演示这个问题。 https://github.com/dantwinkler/container-test-embedded-glassfish 如果没有设置参数,这是堆栈跟踪。 如果在嵌入式容器属性中指定了domain.xml,则测试仍会失败,但因为它表示无法找到测试。 下一步是尝试让事情在没有gradle的情况下工作,看看是否是罪魁祸首。 Gradle Worker 1 executing tests. com.foo.service.TestModelServiceTest STANDARD_ERROR Nov 11, 2012 11:30:35 AM com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default. Nov 11, 2012 11:30:38 AM org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory processXMLProbeProviders SEVERE: MNTG0301:Cannot process XML ProbeProvider, xml = META-INF/gfprobe-provider.xml java.lang.IllegalStateException: Provider already […]

WebLogic Server ::服务器不支持J2EE Web模块规范的3.0版

当我尝试使用WebLogic 11g 10.3.5服务器运行应用程序时,它显示“服务器不支持J2EE Web模块规范的3.0版”。 怎么克服这个? 谢谢!

PointerByReference没有返回值

我试图通过JNA从Java调用C ++函数。 我想传入一个字符串,并返回一个字符串。 这是通过使用in参数和out参数完成的。 我使用PointerByReference来表示char** out参数。 对C ++的调用有效,但调用后PointerByReference为null。 我将我的代码基于PointerByReference文档。 我有什么想法我做错了吗? 我已经在C ++中添加了print语句,以确保它不是将指针设置为null,而且绝对不是。 所以我使用JNA的一些必定是错误的。 但是什么? C ++代码 void processRequest(char* input, char** output, int* outputLength) { // Variable output size from processInput std::string sOutput = processInput(input); char* results = new char[sOutput.length() + 1]; strncpy(results, sOutput.c_str(), sOutput.length()); results[sOutput.length()] = ‘\0’; output = &results; outputLength = new int(strlen(results) + […]

java中的OptionalDataException

package com.n; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; public class S implements Serializable { private static final long serialVersionUID = 1L; transient int i; public static void main(String[] args) throws Exception, IOException { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(“c:\\jav\\f.txt”)); S obj1 = new S(10); oos.writeInt(obj1.i); oos.writeObject(obj1); ObjectInputStream ois = […]

在Spring Singleton中创建新实例会造成内存泄漏吗?

我正在维护一个应用程序,并注意到在Spring连接中定义为Singleton的许多对象在其方法中创建了其他对象的新实例。 例如,每次调用login()方法时都会有一个LoginService Singleton创建一个新的LoginDetails实例。 LoginDetails是瞬态的,只有执行login()方法才需要。 我的问题是,如果Spring为LoginService创建了一个单独的对象,那么如何将LoginDetails实例标记为垃圾收集作为对创建它们的对象的引用并使用它们永远不会终止? 我的意思是: public void deleteCustomer(Long customerId, HttpServletRequest request) { CustomerType customerType = new CustomerType(); customerType.setCustomerId(customerId); CustomerDeleteRequestType deleteRequest = new CustomerDeleteRequestType(); deleteRequest.setCustomer(customerType); CustomerDeleteResponseType deleteResponse = mmmwsClient.executeRequest(deleteRequest); log.debug(“Delete Response Recieved from Server for Customer Name Update ” + deleteResponse.getServiceResult()); } 因为使用的字段只是方法变量而不是实例变量,我想当方法完成时会破坏对它们的引用? 我对Spring Singleton的理解是否正确? 谢谢

Spring Mobile – Interceptor没有应用? 设备为空

我正在尝试使用Spring Mobile,但我似乎无法使基本示例正常工作。 我有一种感觉,我错过了一些愚蠢的简单但我无法弄清楚它是什么。 这就是我所拥有的…… 在web.xml中 contextConfigLocation /WEB-INF/applicationContext.xml org.springframework.web.context.ContextLoaderListener deviceResolverRequestFilter org.springframework.mobile.device.DeviceResolverRequestFilter deviceResolverRequestFilter /* 在applicationContext.xml中 在我的Java类中: public class TestAction extends ActionSupport implements ServletRequestAware { // So that we can lookup the current Device private HttpServletRequest request; public void setServletRequest(HttpServletRequest request) { this.request = request; } @Override public String execute() { Device currentDevice = DeviceUtils.getCurrentDevice(request); if (currentDevice.isMobile()) // […]

在包含Streams的2D列表的修改列表中包含未修改列表中的元素

我问这个问题是关于对1D列表做同样的事情,认为将答案应用于2D列表会很容易,但事实并非如此。 基于Holger的答案我的代码,我提出了这个解决方案: //list is of type ArrayList<List> list.stream() .map(l -> Stream.concat( l.subList(0, l.size() – 1).stream().map(i -> i – 2), Stream.of(l.get(l.size() – 1)).collect(Collectors.toList()) )) .collect(Collectors.toList()); 我得到编译时错误Cannot infer type argument(s) for map(Function) ,但是,当我尝试这个时。 如何在2D列表上执行此function? 一些示例输入和输出: [[1, 2, 3, 4], [5, 6, 7, 8]]应输出[[-1, 0, 1, 4], [3, 4, 5, 8]]

你如何编写一个允许特殊字符DOT的正则表达式?

你如何编写一个允许用户名中的字符DOT(。)的正则表达式? 例如: R. Robert XA Pauline

如何将ascii流绑定到预准备语句

我正在测试官方teradata网站上的 fastload示例代码。 为了谨慎起见,我使用样本上的FastLoad1.csv样本FastLoad1.csv在这里 当我运行此示例代码时,我在此行中收到错误 pstmtFld.setAsciiStream(1, dataStream, -1); // This method is not implemented setAsciiStream如何与预准备语句一起使用? 我正确使用setAsciiStream吗? 这是控制台中的错误消息 Attempting connection to Teradata with FastLoadCSV. Connection to Teradata with FastLoadCSV established. Creating a PreparedStatement object with FastLoadCSV. Created a PreparedStatement object with FastLoadCSV. Checking connection for warnings Streaming FastLoad1.csv SQL State = HY000, Error Code = 1151 com.teradata.jdbc.jdbc_4.util.JDBCException: […]