我几个月前开发了一些Android应用程序项目,它包括,
当时它运行良好.昨天我尝试在真实设备上运行它,我发现它无法进行任何Web服务调用.我在模拟器上期待同样的东西.但令我惊讶的是它在模拟器上运行良好 .....
我在真实设备上获得的异常是:ConnectionTimeOutException.
我想知道摆脱这个问题出了什么问题.我不确定我应该发布什么更多的信息.请问你是否要我发布一些东西
编辑:
AsyncTask<Void, Void, Boolean> gettingHttpOTP = new AsyncTask<Void, Void,Boolean>(){
HttpResponse httpresponse;
HttpClient client ;
JSONObject objSendjson;
HttpPost post ;
HttpEntity entity;
String result;
JSONObject objRetrievejson;
@Override
protected Boolean doInBackground(Void... arg0) {
client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 50000);
objSendjson = new JSONObject();
try
{
post = new HttpPost(Configurations.API_VERIFY_END_USER);
objSendjson.put("Mobile_Number", gCountryCodeAndMobileNumber);
objSendjson.put("Signature_Key", Configurations.SIGNATUREKEY);
post.setHeader("Content-type", "application/json");
post.setEntity(new StringEntity(objSendjson.toString(), "UTF-8"));
httpresponse = client.execute(post);
entity = httpresponse.getEntity();
gHttpResponseCode=httpresponse .getStatusLine().getStatusCode();
if(gHttpResponseCode==200)
{ …Run Code Online (Sandbox Code Playgroud) 如何从图片中获取图片中的图像?onActivityResult没有在片段中调用..这是我在片段中编写的代码
img_user.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
}
});
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (data != null) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContext().getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
img_user.setImageBitmap(BitmapFactory.decodeFile(picturePath));
cursor.close`enter code here`();
} else {
Toast.makeText(getActivity(), "Try Again!!", Toast.LENGTH_SHORT)
.show();
}
}
Run Code Online (Sandbox Code Playgroud) 我想要基于创建日期的文件列表。当我更新任何if图像并尝试检索所有图像时,则随机更改顺序。
这是我的代码,
File[] files = parentDir.listFiles();
for (File file : files) {
// I am getting files here
}
Run Code Online (Sandbox Code Playgroud)
任何帮助..
我的问题是:
问1.如何在JBOSS中启用程序包扫描,以便它可以知道在war文件中查找实现类和提供程序(使用@Provider注释的提供程序)的位置?
问2.为什么我的过滤器没有被应用程序类注册,我必须在web.xml中进行注册?
脚本
我使用Jersey创建了一个Jax-RS Web服务并将其部署在JBOSS-6中,首先我遇到了一个错误,该错误描述了JBOSS无法扫描我在web.xml中提供的包以找到我的Rest Web服务实现.所以周围的方法是创建一个Application类,(我ResourceConfig没有特别的原因阻止自己使用Jersey本身提供的)并在getClasses方法中注册我的WebService实现,如下所示:
public class MainApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
HashSet<Class<?>> set = new HashSet<Class<?>>();
set.add(RESTWSImplementation.class);
set.add(SomeFilter.class);
return set;
}
}
Run Code Online (Sandbox Code Playgroud)
它对我来说有点诡计,但过滤器仍未注册.即
set.add(SomeFilter.class);
Run Code Online (Sandbox Code Playgroud)
好像没有用,所以我在web.xml中提到了过滤器,如下所示,
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>test.SomeFilter</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)
一切都很完美.然而,从下面的文字,我期待它立即注册.
所以我的问题再次出现了,
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>POCTEST</groupId>
<artifactId>POCTEST</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId> …Run Code Online (Sandbox Code Playgroud) 我创建了下图。我只是无法理解在 Spring Webflux/Project Reactor 的情况下线程如何不被阻塞。
在下图中,请求到达我的 Netty 服务器,其中一个线程 (reactor-http-nio-1) 被分配给该请求,它传递流,然后可用于下一步工作。
一段时间后,响应到来并被分配给 Thread2 (reactor-http-nio-2)。它被退回给客户。
但是必须有一些东西,对吧,应该等待响应(或处于阻塞状态),或者在收到响应时唤醒的东西,并且它知道必须为响应分配一个线程,然后线程返回响应发送给提出该请求的各自客户,以防止交错。
我的理解是否正确,仍然涉及阻塞,但我们刚刚将阻塞过程卸载到其他线程(可能是内部线程)。或者系统是否有足够的能力在传递请求后进入休眠状态,并仅在响应到达时唤醒。如果是后者,这个机制是如何运作的?
这个问题可能太宽泛,但一些资源或解释对于澄清确实很有帮助。
新学习java和输入,我们做了
Scanner scan = new Scanner(System.in);
String name;
System.out.println("What is your name?");
name = scan.nextLine();
System.out.println(name);
Run Code Online (Sandbox Code Playgroud)
然而,我发现
Scanner scan = new Scanner(System.in);
String name = scan.nextLine();
System.out.println(name);
Run Code Online (Sandbox Code Playgroud)
工作原理是一样的。这是以更大的形式教给我的,因为它更常用/更清晰,还是因为我是初学者,所以我只是被教更大的形式,以避免太多混乱?(基本上,人们会使用扩展版本而不是压缩版本有什么原因吗?)
我写了下面的代码(参见问题的代码注释),
#include<stdio.h>
int main()
{
int size;
scanf("%d",&size);
int arr[size]; /*is it a valid statement?*/
for(int i=1;i<=size;i++)
{
scanf("%d",&arr[i]);
printf("%d",arr[i]);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个名为 ThreadClass 的类(如您所见,这是一个线程),其结构类似于以下内容
class SomeTask implements Runnable
{
boolean someCondition=true;
public void run() {
try
{
while(someCondition)
{
//Here goes the Process Code
}
}
catch(Exception errorException)
{
//Catching the Exception
}
finally
{
////I expect that this finally should run every time ,whatever happens in the world
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是关于finally块和stop()方法
由于上面的类正在实现 Runnable,所以我可以创建这个类的对象并通过调用start()方法启动它的一个线程。我也知道我可以使用stop()停止这个线程(是的,我知道它已被弃用) 方法。
我想澄清的是,如果我需要以某种方式调用 ThreadClass 对象上的 stop 方法,那么即使线程通过调用stop()停止,我也可以依靠finally块来执行,因为我正在做一些重要的事情在 finally 块中关闭东西。
下面是一个组件,我将在其他各种组件中扩展它以重用一些代码..
import { Component } from '@angular/core';
@Component ({
selector: 'my-app',
template: ` <div>
<h1>{{appTitle}}</h1>
<div>To Tutorials Point</div>
</div> `,
})
export class AppComponent {
appTitle: string = 'Welcome';
ngOnInit(){
this.registerSomeSubscriptions();
}
registerSomeSubscriptions(){
this.subscribeSomething.subscribe((data)=>{
performSomeAction();
})
}
}
Run Code Online (Sandbox Code Playgroud)
我可以像下面这样扩展它
import { Component } from '@angular/core';
@Component ({
selector: 'my-app',
template: ` <div>
<h1>{{appTitle}}</h1>
<div>To Tutorials Point</div>
</div> `,
})
export class ChildComponent extends AppComponent {
}
Run Code Online (Sandbox Code Playgroud)
虽然我知道组件的公共成员将在子组件中可用。
我的问题
我正在从用户手册中学习 php。现在我正在查看以下代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
/* More complex example, with variables. */
class foo
{
var $foo;
var $bar;
function foo()
{
$this->foo = 'Foo';
$this->bar = array('Bar1', 'Bar2', 'Bar3');
}
}
$foo = new foo();
$name = 'MyName';
echo <<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print …Run Code Online (Sandbox Code Playgroud) java ×4
android ×3
angular ×1
arrays ×1
c ×1
file ×1
inheritance ×1
jax-rs ×1
jboss ×1
jersey ×1
nonblocking ×1
php ×1
subscription ×1
web-services ×1