Android:使用Volley发布到Laravel不起作用(Android: posting to Laravel with Volley doesn't work)
我正在使用谷歌排球库来处理我的应用程序网络。
我的后端是一台带有Laravel 4的apache服务器。 当我尝试使用JsonObjectRequest发出POST请求时,我得到一个空的
$_POST
数组。我能够使用这里描述的方法解决它: Volley JsonObjectRequest Post请求不起作用
但对于对象不是很复杂的简单情况,它似乎是一种解决方案。 此外,我想使用Gson和自定义GsonRequest,但它给出了同样的问题。
对我来说似乎很奇怪,特别是Laravel不知道如何处理JSON请求,因为这是一个REST框架,我错过了什么? 有没有更好的方法来解决它?
I'm using google Volley library to handle my application networking.
My backend is an apache server with Laravel 4. When i'm trying to make a POST request using JsonObjectRequest I'm getting an empty
$_POST
array.I was able to solve it using the method described here: Volley JsonObjectRequest Post request not working
but it seems like a solution for simple cases where the object is not very complicated. Also, i'd like to use Gson and a custom GsonRequest, but it gives the same problem.
Seems odd to me that php and especially Laravel don't know how to deal with JSON requests as this is a REST framework, am I missing something? Is there a better way to solve it?
原文:https://stackoverflow.com/questions/20957104
最满意答案
你错过了'循环'。
您不应该在已启动的线程上手动调用run。
public void run() { while (true) { // do whatever Thread.sleep(wait); } }
我实际上也不会使用上面的,我会使用Timer或Android等价物。 你应该从中得到这个概念。
You are missing your 'loop'.
You should NOT call run manually on an already started thread.
public void run() { while (true) { // do whatever Thread.sleep(wait); } }
I would not actually use the above either, I'd use a Timer or Android equivalent. You should get the concept from this though.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
怎么样; a = 10 b = 8 result = 0 loop(b) { last = 0 times = 0; loop(a) { last = times times = inc(times) } result = a = last } result is 2 Js例如; var a = 10; var b = 8; var result; for (var _b = 0; _b < b; _b++) { var last = 0 ...
-
万一它帮助任何人,解决了删除无限循环并添加此方法 Timer timer = new Timer(); timer.schedule( new TimerTask() { public void run() { repaint();} }, 0, 1000); in case it helps anyone, solved deleting the infinite loop and adding this method Timer timer = new Timer(); timer.schedule( ...
-
希望这可以帮助 $inc = $a < $b ? 1: -1; for ($i = $a; $i != $b; $i += $inc) { /* some code here */ } 说明: 第一步是估计增量,即增加或减少$ a到达$ b。 显然,如果$ a <$ b则需要增量或减少。 $ i + = $ inc是添加+1或-1的通用语句。 添加+1是递增,加-1是递减。 最终循环退出条件是$ i!= $ b,希望这个条件在增量/减量中至少满足一次。 Hope this helps $inc = ...
-
我想我找到了方法,我使用以下方法,它可以工作。 我不知道是否有更好的解决方案 final Duration oneFrameAmt = Duration.millis(1000/10); final KeyFrame oneFrame = new KeyFrame(oneFrameAmt,new EventHandler
() { @Override public void handle(ActionEvent ... -
为了让Tassos的答案奏效,你实际上必须创建一个新的线程,而你并没有这样做。 只需打电话 ThreadTester example = new ThreadTester(2,this); example.run(); 是不够的,只是从EDT调用run方法。 您需要执行以下操作: Thread t = new Thread(new ThreadTester(2,this)); t.start(); 请参阅定义和启动线程 。 另外,你想从两个不同的线程( runnable )修改相同的字段,这是一个错误。 ...
-
只要没有回电给你的双胞胎控制器就没问题。 你可能会得到更多的twincontrol更严格的necc,但多数民众赞成在所有。 As long as there isn't a call back to your twincontrol that should be fine. You might get the twincontrol updating more often than strictly necc but thats all.
-
你错过了'循环'。 您不应该在已启动的线程上手动调用run。 public void run() { while (true) { // do whatever Thread.sleep(wait); } } 我实际上也不会使用上面的,我会使用Timer或Android等价物。 你应该从中得到这个概念。 You are missing your 'loop'. You should NOT call run manually on an already started thre ...
-
你的直觉是正确的:以状态作为参数的递归循环是标准的Erlang方法。 通常使用OTP中的一个服务器行为来抽象出这个概念。 简单的例子,可能包含错误: game_loop(X, Y) -> receive {moveto, {NewX, NewY}} -> notifyClient(NewX, NewY), game_loop(NewX, NewY) end. Your intuition is correct: a recur ...