简体   繁体   English

如何将我的 Android 应用程序连接到后端?

[英]How do I connect my Android app to backend?

I want to connect my Android App to the back-end.我想将我的 Android 应用程序连接到后端。 The aim of the project is to filter spam messages.该项目的目的是过滤垃圾邮件。 So the app receives SMSs and then should forward it to server for spam filtering which uses machine learning.因此,该应用程序接收短信,然后应将其转发到服务器进行垃圾邮件过滤,该服务器使用机器学习。 Now, the thing is we have a python program for machine learning but I don't know how to connect these two things - the Android app and the python program.现在,问题是我们有一个用于机器学习的 python 程序,但我不知道如何连接这两个东西 - Android 应用程序和 python 程序。 Need guidance on how the app can send data(sms) and receive response(whether spam of not) to and from the server-side.需要有关应用程序如何向服务器端发送数据(短信)和接收响应(是否不是垃圾邮件)的指导。

A common approach is to connect your client with a web backend that offers a web API (might be a REST API).一种常见的方法是将您的客户端与提供 web API 的 web 后端连接(可能是 Z5073860F47F655EE0 APID)。

Here is a short overview over this topic: https://www.webiotic.com/api-for-mobile-apps/以下是对该主题的简短概述: https://www.webiotic.com/api-for-mobile-apps/

What you need is a web server which can receive web calls and send back information.您需要的是一个 web 服务器,它可以接收 web 呼叫并发回信息。 A web server in this sense is just a program which listens to incoming HTTP calls.从这个意义上说,web 服务器只是一个监听传入 HTTP 调用的程序。

In your case, this might look like this:在您的情况下,这可能如下所示:

  • The server is programmed to listen to web calls with the HTTP method POST on the route /checkMessage服务器被编程为在路由/checkMessage上使用 HTTP 方法POST监听 web 调用
  • It expects the message data in a certain format它期望消息数据采用某种格式
  • For example in JSON with this content: {"message":"Your actual SMS message"}例如在 JSON 中,内容如下: {"message":"Your actual SMS message"}
  • the server checks its database or triggers a ML job服务器检查其数据库或触发 ML 作业
  • server returns a result in a specified format.服务器以指定格式返回结果。 For example this JSON: {"isSpam":true}例如这个 JSON: {"isSpam":true}
  • Your app then needs to send a POST call to https://www.[YOUR_URL]/checkMessage with the specified data and wait for a response然后,您的应用需要使用指定的数据向https://www.[YOUR_URL]/checkMessage发送POST调用并等待响应
  • There are libraries for android which help you with that like Retrofit or OKHttp有 android 的库可以帮助您解决问题,例如RetrofitOKHttp

As for which technology to use: It's up to you.至于使用哪种技术:由您决定。 You can create a web backend in pretty much every language.您可以使用几乎所有语言创建 web 后端。 In your case, you should check out which Python libraries are available to listen to HTTP connections.在您的情况下,您应该检查哪些 Python 库可用于侦听 HTTP 连接。

Keep in mind that if your app can publicly access your backend, then everybody else can as well.请记住,如果您的应用程序可以公开访问您的后端,那么其他人也可以。 You will want to add some kind of authentication as well.您还需要添加某种身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将我的Android应用程序连接到我的PHP / MySQL后端? - How to connect my Android app to my PHP/MySQL backend? 如何将我的Android应用程序连接到远程MySQL数据库? - How do I connect my Android app to a remote MySQL database? 我如何将Android应用程序连接到Django后端 - How can I connect android app to django backend 如何安全地确定尝试连接到后端服务器的android应用是我的正版应用? - How to securly veify that an android app that is trying to connect to my backend server is my genuine app? 如何将数据库连接到 Android 应用程序? - How do I connect a database to an Android app? 如何将 webapp 与 android 应用程序连接起来? - How do I connect webapp with android app? 我如何在 Android 应用程序中模拟 REST 后端 - How do i mock REST backend in an android app 如何解决我的 Meteor Android 应用程序无法连接的问题? - How do I resolve this issue where my Meteor Android app doesn't connect? 如何将Android应用程序连接到笔记本电脑,PC或服务器上的MySQL数据库? - How do I connect my Android app to a MySQL database on a laptop, PC, or server? 如何将存储在AWS S3服务器中的sqlite数据库远程连接到我的android应用 - How do I connect a sqlite DB stored in AWS S3 server to my android app remotely
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM