android网络编程

This article is a short foray into how I setup my development environment in on an Android phone to do some web programming.

本文简短介绍了如何在Android手机上设置开发环境以进行一些Web编程。

开始之前 (Before we begin)

A question that I had to deal with initially was whether the need is there to do such a thing. We live in an world where my virtual server at a place like DigitalOcean is an ssh connection away from being accessed. Why setup a complete, standalone server on my phone at all?

我最初必须处理的一个问题是是否有必要这样做。 我们生活在一个这样的世界中,我的虚拟服务器在DigitalOcean之类的地方是SSH连接,无法访问。 为什么要在手机上完全设置完整的独立服务器?

The intrigue. The possibility. That’s all I can offer for an answer. It’s not a novel idea at all. But the usability of such a setup has not really been explored. How far you can get development on a phone? What can be done on a form factor that is rarely considered a development device? My initial experience was very rough around the edges. Moving from an IDE like VS Code was difficult. Moving from a physical keyboard to a less than programmer friendly touchscreen keyboard was a hassle. Moving from a window desktop environment to the command line was not that bad but had to have some getting used to.

阴谋诡计。 可能性。 这就是我所能提供的答案。 这根本不是一个新主意。 但是,尚未真正探讨过这种设置的可用性。 您可以在手机上进行多远的开发? 在很少被视为开发设备的外形尺寸上可以做什么? 我最初的经验是非常粗糙的。 从像VS Code这样的IDE迁移是困难的。 从物理键盘转移到对程序员不友好的触摸屏键盘是很麻烦的。 从Windows桌面环境移到命令行并不是很糟糕,但是必须要习惯一些。

All in all, it’s great for a hobbyist web programmer like me. I been using this setup for a couple of months now and prefer to work on the comforts of my bed and as a way to pass time while I use public commutes. It sure beats carrying a laptop around.

总而言之,对于像我这样的业余Web程序员来说,这很棒。 我已经使用这种设置几个月了,并且更喜欢在舒适的床上工作,并以此作为在使用公共通勤时打发时间的一种方式。 它肯定比随身携带一台笔记本电脑好。

Even though I use the term ‘phone’ extensively through out this discussions an Android Tablet can also be used for this same setup.

即使在整个讨论过程中我都广泛使用“电话”一词,Android Tablet也可以用于相同的设置。

设置Termux (Setting up Termux)

最好的终端模拟器 (The greatest terminal emulator)

If you are Linux enthusiast, than Termux is really a godsend. The main distaste I had for Android phone is that even while using the Linux kernel (or patched kernel), it doesn’t feel linux-ey. Not at all. While this may have worked out in it’s popularity for the mainstream, it left an unscratched itch for people like me.

如果您是Linux爱好者, 那么Termux确实是天赐之物。 我对Android手机的主要不满之处在于,即使使用Linux内核(或修补的内核),也感觉不到linux-ey。 一点也不。 尽管这可能已经在主流中得到了解决,但它给像我这样的人留下了一点痒。

Termux, with Webpack compilation process running
Termux,运行Webpack编译过程

Sure, there were terminal emulators from the beginning but they were very basic. It was also possible to get a full Linux distribution running on a rooted phone but I’ve not been comfortable rooting devices (voiding warranty has never been my cup of tea).

当然,从一开始就有终端仿真器,但是它们是非常基础的。 也有可能在有根电话上运行完整的Linux发行版,但我对根设备不满意(避免保修从来不是我要的)。

Termux successfully satisfied all the needs that plain Android and it’s terminal emulators never could.

Termux成功满足了普通Android及其终端仿真器无法满足的所有需求。

Termux is a like a patched Linux distribution for your Android. Well it’s not even that. According to the developer’s description:

Termux就像是为您的Android修补的Linux发行版。 好吧,那还不是。 根据开发商的描述:

“Termux provides a package ecosystem similar to the one in Linux distributions. However you should be aware that Termux is just a regular application running on Android OS” — Termux Wiki

“ Termux提供了一种与Linux发行版中的软件包类似的软件包生态系统。 但是,您应该意识到Termux只是运行在Android OS上的常规应用程序” – Termux Wiki

Don’t let that distress you. Great thing about Termux, compared to other terminal emulators available on Android is the list of packages made available to you. If that list is exhaustive, you can even install a full Linux distribution, on top of your android system, even without a root device.

不要让那困扰你。 与Android上可用的其他终端仿真器相比,Termux的伟大之处是为您提供了软件包列表。 如果该列表详尽无遗,即使没有根设备 ,您甚至可以在android系统之上安装完整的Linux发行版 。

First install Termux from Playstore. If you would like to support the developer it’s a good idea to buy the couple of extensions that are available.

首先从Playstore安装Termux 。 如果您想支持开发人员,则最好购买几个可用的扩展 。

After installing Termux and reading up on how it’s package management works, it’s time to decide your development stack. PHP? MySQL? Apache? Ruby on Rails? NodeJS? It’s all there in the Termux repos. Termux wiki gives a straightforward installation guide to most of these packages and whether there is any Termux specific tasks that need to be done.

安装Termux并阅读其软件包管理的工作原理之后,该决定您的开发堆栈了。 PHP的? MySQL的? 阿帕奇? Ruby on Rails? NodeJS? Termux仓库中都有这些。 Termux Wiki为大多数这些软件包以及是否有需要完成的Termux特定任务提供了直接的安装指南。

Irrespective of your programming language, libraries and frameworks you choose, you’ll probably want to install the following anyway.

无论您选择哪种编程语言,库和框架,都可能仍要安装以下内容。

  1. Git (for version controlling and pushing code to production site)Git(用于版本控制和将代码推送到生产站点)
  2. OpenSSH (ssh connections back and forth from your phone)OpenSSH(通过手机来回建立SSH连接)

You might also want to change the default shell (bash) to something more feature full such as zsh or fish. Oh-my-zsh and Oh-my-fish packages are also works just as well as they do in Linux distributions.

您可能还想将默认的shell(bash)更改为功能更完整的东西,例如zsh或fish。 Oh-my-zsh和Oh-my-fish软件包也与Linux发行版中的软件包一样有效。

设置Vim (Setting up Vim)

最伟大的编辑? (The greatest editor?)

Vim with some Vue code
带有一些Vue代码的Vim

Vim deserves all the accolades of praises it gets, at least in my book. But the text on my book might vary from what you follow, so it’s fair to suggest that this step is not really a requirement. You can go for another text editor available in the repos:

Vim值得赞扬,至少在我的书中如此。 但是我的书上的文字可能与您所遵循的内容有所不同,因此可以公平地建议这一步骤并不是必需的。 您可以在存储库中使用另一个文本编辑器:

  1. Emacs埃马克斯
  2. Nano奈米
  3. Vi六
  4. The list really goes on…名单确实还在继续……

Another possibility is to hookup your development files to a directory that’s also externally available on your Android system¹. Then you can get a code editor from PlayStore and get on developing from there. Your development is still local to the phone.

另一种可能性是将开发文件连接到一个目录,该目录在Android系统上也可以从外部获得。¹ 然后,您可以从PlayStore获取代码编辑器,然后从那里开始开发。 您的开发仍在电话本地进行。

I prefer Vim. The use of an external code editor outside of the command line may seem appealing to some, specially those coming to Termux after using an IDE or even a code editor like VS Code or Sublime. Much about Vim has already been said before elsewhere by more competent developers than me so I’ll not go into that discussion. To install Vim on Termux run the following.

我更喜欢Vim。 对于某些人来说,在命令行外部使用外部代码编辑器似乎很有吸引力,尤其是那些在使用IDE或什至是VS Code或Sublime之类的代码编辑器后进入Termux的人。 比我更能干的开发人员之前已经在其他地方谈论过有关Vim的很多内容,所以我不再赘述。 要在Termux上安装Vim,请运行以下命令。

pkg install vim

pkg install vim

After installation of all the dependencies and the main packages you are good to go. Just type the command as you would on any other terminal.

安装所有依赖项和主要软件包后,您就可以开始了。 只需像在其他终端上一样键入命令即可。

vim

vim

Vim is extensible with loads of plugins but after some research I decided to keep vim as vanilla as possible. The type of plugins you would use depends on your workflow and the language you are going to use. It may seem appealing to go and install some fancy plugins that are out there such as NERDTree and YCM² but note that some of these plugins are not really for mobile use.

Vim是可扩展的,带有许多插件,但是经过一番研究,我决定将Vim保持尽可能原始。 您将使用的插件类型取决于您的工作流程和要使用的语言。 它可能看起来很有吸引力去安装一些花哨的插件是在那里如NERDTree和YCM ²但请注意,其中一些插件并不是真正的移动使用。

Setting up Vim to be the way you like it may take some time and if you have no experience using Vim, the learning curve will surely be steep but its worth the while.

将Vim设置为您喜欢的方式可能会花费一些时间,如果您没有使用Vim的经验,则学习曲线肯定会比较陡峭,但值得一试。

The plugins I use for Vim in my development are

我在开发中用于Vim的插件是

  1. Vundle (plugin manager)

    Vundle (插件管理器)

  2. AutoPairs (for bracket completion)

    自动配对 (用于完成括号)

  3. Vim-vue (syntax highlighting for Vue.js)

    Vim-vue (Vue.js的语法突出显示)

  4. Snipmate (for snippet suggestion) and some additional dependent extensions

    Snipmate (针对代码段建议)和一些额外的依赖性扩展

  5. Vim-snippets (snippet engine that supports Snipmate)

    Vim代码段 (支持Snipmate的代码段引擎)

All of those plugins are really only for my use case. If you don’t use Vue, for example, you would not need Vim-vue. If you have a preference for a plugin manager other than Vundle, for example Pathogen, you would use that instead.

所有这些插件实际上仅用于我的用例。 例如,如果您不使用Vue,则不需要Vim-vue。 如果您偏好使用Vundle以外的其他插件管理器(例如Pathogen) ,则可以改用它。

处理一些警告 (Handling some caveats)

Web开发人员工具 (Web developer tools)

There is one caveat to web development on your android phone which needs to be addressed. If you open up Chrome (or any other mobile web browser for that matter) you will find that none offers web developer tools. No access to a console, no debugging tools, not even a way to check the HTML code! This was all for naught, you might be thinking.

在您的android手机上进行Web开发有一个警告,需要解决。 如果您打开Chrome(或与此有关的任何其他移动网络浏览器),将发现没有提供Web开发人员工具的工具。 无法访问控制台,调试工具,甚至无法检查HTML代码! 您可能会想,这都是徒劳的。

Chrome web browser does offer a remote way of checking mobile pages on the desktop browser’s web developer tools. I’ve never used it. It beats my purpose of doing all my development and debugging on my phone. It may not be the case for you so a small research should help you decide if that’s the path you would go.

Chrome网络浏览器确实提供了一种远程检查桌面浏览器的网络开发者工具上的移动页面的方法 。 我没用过 这超出了我在手机上进行所有开发和调试的目的。 对于您而言可能并非如此,因此进行少量研究可以帮助您确定这是否是您要走的路。

A better and more preferable choice for me was to use Eruda.

对我来说,更好和更可取的选择是使用Eruda 。

Left: Eruda floating button, neatly tucking everything away. Right: Eruda developer tools
左:Eruda浮动按钮,将所有东西整齐地藏起来。 右:Eruda开发人员工具

A web developers tool bar directly integrated into your web application, courtesy of JavaScript. It offers pretty much everything I need, and is neatly tucked away from view with the use of a hover button to activate and deactivate it. Needless to say, without Eruda, my foray into web development on mobile would have been a total failure. To put it simply, as of now, Eruda is a must for me and probably for you as well.

Web开发人员工具栏,直接通过JavaScript集成到您的Web应用程序中。 它提供了我所需的几乎所有东西,并且使用悬停按钮来激活和停用它,从而将其整齐地隐藏在视野之外。 不用说,如果没有Eruda,我进入移动Web开发的尝试将完全失败。 简而言之,到目前为止,Eruda对我来说可能是必需品,对您也同样是必需品。

键盘 (Keyboard)

Another difficulty is the keyboard. All your useful brackets are usually hidden away, and finding the caret is a pain. One option is to use a more programmer friendly keyboard. These keyboards, although useful, was not the best experience, as they needed to be switched out constantly when you are using your phone for not programming, like any normal person. The button sizes are also another inconvenience.

另一个困难是键盘。 通常,您所有有用的括号都被隐藏起来了,找到插入符是很痛苦的。 一种选择是使用对程序员更友好的键盘 。 这些键盘虽然有用,但并不是最好的体验,因为当您像其他普通人一样使用手机进行编程时,需要不断关闭它们。 按钮的尺寸也是另一个不便之处。

接下来要去哪里? (Where to next?)

With the setup in place, you have a powerful and capable, development environment directly in your hand, literally. Both the front end and back end development within your grasp. How you would use it depends on what you are trying to create. You could:

实际上,安装完成后,您将直接拥有一个强大而强大的开发环境。 您可以掌握前端和后端的开发。 您将如何使用它取决于您要创建的内容。 你可以:

  • Install LAMP stack or LEMP stack. Install composer and use Laravel, in a manner you would usually do so on your PC.

    安装LAMP堆栈或LEMP堆栈。 以通常在PC上进行安装的方式安装composer并使用Laravel 。

  • Install MEAN stack and use one of the many libraries (sails.js, feathersjs, ember.js, react) alongside Webpack³

    安装MEAN栈并使用许多库中的一个( sails.js , feathersjs , ember.js , React )一起Webpack³

  • Install Ruby and go ahead with development using Ruby on Rails

    安装Ruby并继续使用Ruby on Rails进行开发

You will encounter problems that you will need to sidestep and create solutions for. Termux, is not a fully fledged Linux distribution so all the packages that you get have been patched in one way or the other to work on your Android device. I’ve had problems getting some NPM packages that relied on other programs that could not be ported to Termux. Such instances have been very minimal in my experience.

您将遇到需要回避并为其创建解决方案的问题。 Termux不是完全成熟的Linux发行版,因此您所获得的所有软件包都已以一种或另一种方式进行了修补,以在Android设备上工作。 我在获取一些依赖于无法移植到Termux的其他程序的NPM软件包时遇到了问题。 以我的经验,这种情况很少。

Irrespective of the experience, this is the most fun I’ve had in web programming in a long time.

无论经历如何,这都是我很长时间以来在Web编程中获得的最大乐趣。

  1. Termux files are not accessible from the Android system, but the Android SD card can be accessed from Termux

    无法从Android系统访问Termux文件,但 可以从Termux访问Android SD卡

  2. To get YCM (You-Complete-Me) to work, you will need to go about a lot of hassle and install vim-python instead of vim. I was not able to get it working after many attempts

    要使YCM(You-Complete-Me)正常工作,您将需要花费很多精力并安装vim-python而不是vim。 经过多次尝试,我无法使其正常工作

翻译自: https://medium.com/swlh/web-programming-on-android-e3954bb49358

android网络编程


http://www.taodudu.cc/news/show-5902898.html

相关文章:

  • 安卓开发指南!万字长文总结Android多进程,实战解析
  • 安卓开发权威指南!2021大厂Android面试经验,不吃透都对不起自己
  • 名帖100 赵孟頫 小楷《无逸篇》
  • 书论70 何良俊《四友斋书论》
  • 书论63 汤临初《书指》
  • 书论89 刘熙载《书概》
  • 书论88 何绍基《论书》
  • 苹果logo_苹果推送5款联名AirPods Pro耳机壳/VIVO推出印度制造LOGO/荷兰Indigo设计奖获奖名单...
  • 苹果历代产品中的8大亮点设计(下)
  • Mac无法连接Apple所有服务-解决方法
  • apple silicon m1软件适配进度
  • ios上架应用违反了PLA的第3.2(f)节被封问题详解
  • 无法打开mysql因为apple_无法打开“XXXX”,因为Apple无法检查其是否包含恶意软件。怎么解决?...
  • 苹果M1芯片兼容mysql吗_Apple M1芯片电脑 软件兼容情况
  • appstore数据抓取
  • 注册icoke帐户换积分免费获得QQ3D秀(转)
  • Sorry, you have been blocked(Chatgpt登录被屏蔽)
  • chatgpt报错:Sorry, you have been blocked解决方法
  • ChatGPT报错“Sorry You Have Been Blocked“ 解决办法
  • 零基础语法入门第二讲 be动词的形式和用法
  • 队友总抢好装备, 互斥模式(Mutex Pattern)来安慰
  • [题解]CF Round #386 (Div.2)
  • CF464D World of Darkraft - 2(期望DP)
  • NEFU CF 练习赛 45
  • Codeforces Round #560 (Div. 3)F1.F2. Microtransactions (easy version)
  • CF1366 EDU89 菜鸡的ABC题解
  • CF464D World of Darkraft - 2
  • 93年女生400栋楼收租引发巨大争议:真正的“后浪”是什么样子?
  • 【英语】100个句子记完5500个考研单词
  • 别忘了人生另外三分之二的风景

android网络编程_Android上的网络编程相关推荐

  1. 《c语言从入门到精通》看书笔记——第16章 网络套接字编程(上)——网络

    1.IP地址 每台计算机都需要一个IP地址以识别自己,IP地址由IP协议规定的32位的二进制表示,最新的IPV6协议将IP地址提升为128位,但还不能广泛应用. 32位的IP地址主要分为前缀和后最两部 ...

  2. 计算机可用网络连接不上,电脑网络连接不可用?学会这招,轻松解决

    原标题:电脑网络连接不可用?学会这招,轻松解决 上面 电脑用久了总是会出现各种各样的问题,最常见的要数网络问题了,有不少用户反映说网络连接不可用,上不了网很烦 躁,那么如果用户遇到Win10网络连接不 ...

  3. java监听网络连接_Android RxJava 之网络链接监听示范

    RxJava在stream events处理上真的是一个利器.下面的示范代码显示如何用它来监听android设备的网络连接状况,实时接收change信息. IntentFilter filter = ...

  4. 笔记本的网络出现红叉,网络连接不上,网络不可用

    笔记本的网络突然出现如下问题时: 解决方法: 1.点击网络和Internet设置,如下图所示: 2.再点击更改适配器选项,出现如下的情况: 3.点击此电脑,在点击上方的计算机,再点击管理: 4.再点击 ...

  5. c语言函数视频编程,史上最高效编程学习方法,十分钟学会使用C语言函数

    一.什么是函数 1.C程序的基本单元 C程序中,为了方便规划.编写.调试,需要把程序分模块来编写. 加法 乘法 减法 除法 2.用来实现程序的一些具体的功能 每一个模块实现单一功能. 3.函数注意: ...

  6. 22. 并发编程(上)

    22. 并发编程(上) 网络编程,了解网络相关的知识点并且要知道几乎所有网络的通信本质上都是通过socket模块实现.例如:网站.网络爬虫. 并发编程,提升代码执行的效率.原来代码执行需要20分钟,学 ...

  7. Day22 并发编程(上)

    day22 并发编程(上) 网络编程,了解网络相关的知识点并且要知道几乎所有网络的通信本质上都是通过socket模块实现.例如:网站.网络爬虫. 并发编程,提升代码执行的效率.原来代码执行需要20分钟 ...

  8. Android编程获取网络连接状态及调用网络配置界面

    获取网络连接状态 随着3G和Wifi的推广,越来越多的Android应用程序需要调用网络资源,检测网络连接状态也就成为网络应用程序所必备的功能. Android平台提供了ConnectivityMan ...

  9. Android编程 获取网络连接状态 及调用网络配置界面

    获取网络连接状态 随着3G和Wifi的推广,越来越多的Android应用程序需要调用网络资源,检测网络连接状态也就成为网络应用程序所必备的功能. Android平台提供了ConnectivityMan ...

最新文章

  1. LeetCode刷题记录3——237. Delete Node in a Linked List(easy)
  2. 4 交换机-fanout(订阅发布模式)
  3. rocketmq java home,rocketmq 安装与配置以及遇到的问题
  4. python re findall 效率_python re模块findall()详解
  5. Android 串口开发,发送串口命令,读卡,反扫码,USB通讯,实现demo。——持续更新
  6. 数字图像处理学习笔记(二):SIFT(尺度不变特征变换)算法
  7. idea菜单栏消失如何调整回来
  8. 联想计算机内安装硬盘,联想装固态硬盘教程_联想电脑如何安装固态硬盘-win7之家...
  9. BUUCTF misc 专题(77)间谍启示录
  10. Vue脚手架安装教程
  11. 华为ensp OSPF单区域配置
  12. 简单快速的运行 Zheng 平台(配置篇)
  13. 免费:轻松实现在微信中直接下载APK
  14. 出现Cannot find module 'xxx' 错误
  15. Windows2003 3389端口修改
  16. python游戏编程书_Python游戏编程快速上手 第4版 (斯维加特著) 中文pdf扫描版[41MB]...
  17. c语言编写 构成的梯形,用C语言编写梯形
  18. 第六次网页前端培训笔记(JavaScript)
  19. bs文件服务器,BS在线文件管理系统
  20. Linux中对mariadb数据库的管理

热门文章

  1. 拓嘉启远:拼多多全店推广推广计划无限制叠加,行吗
  2. js实现json和xml之互转
  3. AIX Oracle RAC 升级到10.2.0.4.0要特别注意的问题
  4. 女孩玩鼠标垫玩出百万资产
  5. java程序员面试金典--i++
  6. 第一次做WebService对接遇到的问题
  7. Delphi中Move、CopyMemory操作
  8. 浅谈Linux tty体系,理清tty驱动层次与各种概念
  9. 计算机的发展与应用 教学设计,第二课《计算机的发展与应用》教学设计.docx
  10. Excel的FIND函数和SEARCH函数区别