如何在Android应用程序上基于服务器消息执行不同的任务?

时间:2021-08-09 01:44:25

I created working chat application in android and java based server using TCP/Ip . But now i want to perform tasks like vibration in phone when server send particular string such as "Vibrate" ... I tried if servermsg="Vibrate" (And called another class) but not working... Help Pls....

我使用TCP / IP在基于android和java的服务器上创建了工作聊天应用程序。但是现在我想在服务器发送特定字符串如“振动”时执行电话振动等任务...我试过如果servermsg =“Vibrate”(并且称为另一个类)但是没有工作...帮助请....

1 个解决方案

#1


i would start off by testing your logic to see where the issue is occuring.

我将首先测试你的逻辑,看看问题出在哪里。

for starters, you should print your server message to the console to see what is actually coming back. odds are that it's also wrapped in some kind of json object, so you'll probably need to parse the response also. if you can print the server response and then post it here we can have a read and help you resolve this.

对于初学者,您应该将服务器消息打印到控制台以查看实际返回的内容。可能性是它也包含在某种json对象中,所以你可能还需要解析响应。如果您可以打印服务器响应然后在此处发布,我们可以阅读并帮助您解决此问题。

#1


i would start off by testing your logic to see where the issue is occuring.

我将首先测试你的逻辑,看看问题出在哪里。

for starters, you should print your server message to the console to see what is actually coming back. odds are that it's also wrapped in some kind of json object, so you'll probably need to parse the response also. if you can print the server response and then post it here we can have a read and help you resolve this.

对于初学者,您应该将服务器消息打印到控制台以查看实际返回的内容。可能性是它也包含在某种json对象中,所以你可能还需要解析响应。如果您可以打印服务器响应然后在此处发布,我们可以阅读并帮助您解决此问题。