树莓派android系统,vnc远程访问

A VNC Server for Android allows remotely accessing the device’s screen. In this post, I will show you how to run a VNC server on Android and access its screen remotely.

Let us clear one thing up front. We are not going to be discussing VNC clients for Android. We are going to be looking at the other side of Virtual Network Computing (VNC), which is running an actual VNC server on Android device.

Information on how to remotely access Android device’s homescreen or interface is sparse. Most of the information out there seem to look at the reverse scenario - accessing a remote server on Android device using VNC Client app. Read: Setup VNC Server on Ubuntu: Complete Ubuntu Remote Desktop Guide
Setting up a VNC server for Android just as simple. In this post, I will show you how to setup an Android VNC server without root.

WHAT IS A VNC SERVER?

VNC stands for Virtual Network Computing. It is a way of sharing the graphical desktop of a system to a remote system. In addition to the graphical interface, input events (keyboard, mouse, etc.), audio, and clipboard can also be shared with the remote system.

Xubuntu Desktop From Remote Server On Tightvnc Viewer In Windows

This is a super cool way to access remote systems and works as if you are actually in front of the remote workstation. With my recent move to Proxmox, VNC setup on Ubuntu Server has as been very handy for me. [Read: Ultimate Docker Home Server with Traefik 2, LE, and OAuth / Authelia [2020]]

In this post, we are going to try to access my Android phone’s interface via VNC from a Windows laptop.

What can you do with VNC Server on Android?

Well, this is the million dollar question isn’t it?

In my case, I have Android tablets showing Home Assistant dashboards for home automation. [Read: My Smart Home setup – All gadgets and apps I use in my automated home]

Sometimes I want to check what is showing on the dashboard, which having to be in front of it.

SmartHomeBeginner brings in-depth tutorials easy enough to understand even for beginners. This takes considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:

  • Feeling generous? Buy me a coffee (or two).
  • May be another day? Shop on Amazon using our links. Your prices won’t change but we get a small commission.
  • Don’t feel like spending? You can still show your support by sharing this post, linking to it in forums, or even commenting below.
    That is just one application. If you have other applications you can think, please share with the rest of the us in the comments section.

VNC SERVER FOR ANDROID WITHOUT ROOT

While there are numerous VNC clients for Android, there aren’t many VNC Server Android apps. In fact, when I did my research I could only find one that worked well: droidVNC-NG.

Droidvnc-Ng App - Vnc Server For Android

The best part is, droidVNC-NG app is free. Go ahead, head to the Play store and install droidVNC-NG and let us get started with setting up an Android VNC server. Alternatively, if you have droidVNC-NG VNC server Android apk, install it and proceed.

Is VNC Server free?
It depends on the server app. Some are paid. But there are free ones too (eg. droidVNC-NG for Android). Once a VNC Server is running, there are several free client apps to access the server.

  1. VNC Server Port and Password
    When you open the app, you should see an Android VNC server interface that looks like what is shown in the image below.
    Droidvnc App - Set The Port And Vnc Password

First, provide a port number for VNC server. Typically it is 5900. But you could change it to whatever (typically 59xx). In this Android VNC server guide, I am going to use 5902.

Next, provide a password for the VNC connection. Pick a strong password. In this tutorial, I am picking test (NOT a strong password).

We are not going to be discussing advanced configurations such as VNC through SSH tunnel, which provides an encrypted connection. Therefore, setting up a strong password is a bare minimum for security.

  1. Accessibility Permissions for Android VNC Server
    Next, we need to enable Accessibility permissions for the Android VNC server. This allows remote control of the Android device. So click on Screen Capturing and grant accessibility permissions to droidVNC-NG app, as shown below.

    Enable Android Accessibility Permissions
  2. Grant View and Control Permissions
    We also need to grant view and control permissions to the VNC server for Android. Click on Input to grant this permission in the screens that follow (shown below).

    Enable View And Control Permissions
  3. Grant File Access Permissions to VNC Server on Android
    Finally, click on File Access on the droidVNC-NG app configuration screen. Allow the app to access files on your android device, as shown below.

    Enable File Access Permissions
  4. Start VNC Server on Android
    Finally, hit the start button to start VNC server for Android. You will be presented with the warning screen shown below.

    Sensitive Information Casting Warning!!!

Carefully read and understand the implications prior to continuing. Once started, the Android VNC server should be listening for connections on the port you chose (5902 in this how-to).

Start Android Virtual Network Computing Server

In addition to the port number, you will also need the IP address of the Android device. As shown above, in this guide it is 192.168.1.120, which is the LAN IP address of my Android device.

If you are trying to access an Android system from outside your local network, then remember to setup port-forwarding on your router/gateway.

CONNECT TO ANDROID VNC SERVER

Now that our VNC Server on Android is running, let us see how to access the screen remotely. There are multiple ways to do this.

One of my favorite ways is to use Guacamole, which offers a HTML5 browser based access to VNC servers.

But for simplicity, in this guide, we are going to use TightVNC client for Windows. Using this VNC client app, we will view the Android device from my Windows system.

  1. Provide VNC Server details on the Client app
    Open the VNC client and provide the IP address and port number. In this case, they are 192.168.1.20:5902.
    Connect To Android Vnc Server Using Vnc Client

Wait!!! But the image above shows 2, and not 5902 for port.

As explained previously, VNC ports are usually in the range 5900 to 5999. For VNC ports, it is customary to provide only the incremental number from 5900. Therefore, for port 5902, the increment is 2. The TightVNC client app automatically trims the port number down to just the incremental number.

  1. Provide VNC Password
    Next provide the VNC password that you chose while setting up the VNC Server for Android.
    Enter Vnc Server Password

SmartHomeBeginner brings in-depth tutorials easy enough to understand even for beginners. This takes considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation.
3. Access Android VNC Server on Windows
You should now be able to remotely access and interact with your Android device. You could work on it and control it using your mouse (and keyboard) - mouse-click to select, click and drag to move screen or scroll, etc.

Android Interface Via Vnc Client On Windows

So there you have it - the full graphical interface of Android that can be remotely controlled from practically any platform.

FINAL THOUGHTS ON RUNNING A VNC SERVER ON ANDROID

While this is all fun to do, I want to share my experience in using VNC Server for Android without root. Simply put, the performance was not great and it was not a smooth experience controlling the Android device using a mouse. It was choppy and slow. And this was on my Pixel 3, which has decent specifications at this point (March 2021).

On older Android devices, the experience might be even worse. Nevertheless, the droidVNC-NG app works great, is really one of a kind at this point, and free to use.

There are alternatives such as the VNC Server app from XDA Developers. This app allows both wifi and USB access. Wired access may provide a smoother experience but I have not tried this yet. If you have tried this, I would appreciate if you share your experience in the comments.

Other than that, it was a fun and easy project to setup a VNC Server for Android and access it remotely.

树莓派android系统,无屏远程访问

当树莓派首次安装完Android系统,需要借助屏幕设置wifi密码(暂时没有其他好方案)。设置完成后,能够正常上网,后续操作可以在无屏的方式下,远程访问树莓派。
一般远程访问有多种方案,这里介绍两种方式:

  • vysor投屏
  • vnc投屏

准备工具

  • vysor
  • vnc viewer
  • droidVNC-NG
  • adb
  • mac book & pc

打开Android开发者设置

参考《树莓派安装Android操作系统

方式一:vysor投屏

vysor是一款手机投屏软件,通过PC控制手机。通过官网https://www.vysor.io/ 下载桌面版软件或chrome插件,安装完成后,启动软件。

  • 按照下图,连接adb server:

  • 链接成功后,如下图
  • 点击上图“播放”按钮,开始远程投屏

注意:

  1. vysor可以通过USB或wifi连接(需要收费)。
  2. USB是通过ADB方式连接,同一时间只能一个连接,如Android studio开发联调和vysor投屏会冲突。

方式二:vnc投屏

参考《树莓派android系统,vnc远程访问

树莓派安装Android操作系统

准备工具

  • Raspberry Pi Imager
  • Android 9 OS
  • 16G SD卡
  • Mac Book

制作安装盘

下载Android系统

树莓派4B支持免费Android操作系统,下载地址为:https://konstakang.com/devices/rpi4/ ,选择自己喜欢版本

烧制操作系统

  • 解压下载zip文件
  • 启动Raspberry Pi Imager,选择刚才解压img文件,并选择SD卡,最后点击“烧录”按钮,如下图:

启动系统

  • 将烧制的SD卡插入Raspberry主板
  • 插上电脑屏幕,连接键盘和鼠标
  • 按下开机键,android系统将启动
  • 第一次在Raspberry Pi上启动LineageOS时,看到以下屏幕。点击右下角的 “Next >”按钮,开始初始化。
  • 在下一个屏幕上,选择Android设备使用的语言。可以使用屏幕中间的选项来选择您要使用的语言(1.置后后,请点击 “下一步 >”按钮
  • 现在使用屏幕左侧的下拉框设置设备的时区(1.也可以使用此设置来控制当前的日期和时间。设置好时区后,可以点击 “下一步 >”按钮进行设置
  • 如果没有使用以太网连接,下一个屏幕是设置连接到Wi-Fi。Raspberry Pi应该已经扫描了可用的Wi-Fi网络,点击要连接的网络(1.)。连接后,可以点击 “下一步 “按钮继续
  • 现在可以禁用或启用LineageOS的一些功能。其中一些功能包括隐私保护,可以阻止应用程序在未经批准的情况下读取你的联系人、信息或通话记录。设置好之后,请点击 “Next >”按钮继续进行设置。
  • 最后一个设置页面为的Raspberry Pi支持的Android设备设置PIN、模式或密码。请注意,如果打算安装谷歌应用,建议直接跳到下一步。否则,如果想设置锁屏,请点击 “设置 “按钮(1.如果不想设置密码,请点击 “SKIP >”按钮(2)。
  • 在树莓派上完成Android设置,点击右下角的 “START >”按钮。
  • 最终,进入android桌面。

开启开发者设置

  • 在安卓设备的桌面上,从最下面的三个应用中点击并向上拖动,弹出应用库。
  • 在该菜单内,点击 “设置 “应用。
  • 向下滚动到底部,找到 “关于平板电脑 “选项并点击。
  • 在这个设置页面中,向下滚动到底部,直到看到 “Build Number “的文字。需要点击这个文字(1.),弹出一条信息,通知你 “你已经启用了开发设置!”。应该只需要5次点击就可以启用设置。完成后,点击返回按钮(3.)返回到设置页面。
  • 再次向下滚动到底部,打开 “系统 “设置页面。
  • 请点击本页底部的 “高级 “切换。
  • 滚动到底部,找到 “开发者选项”,然后点击它。
  • 有两个不同的选项,我们需要在这个页面中进行配置。首先,向下滚动,直到你看到 “Root access”,然后点击它。
  • 在弹窗中,我们需要同时启用 “Apps和ADB “的root权限。点击相应的选项进行操作。
  • 最后,会被警告关于在你的Android设备上启用root权限可能带来的影响。需要root权限,点击 “确定 “按钮。
  • 接下来,需要下拉到 “本地终端 “选项,点击切换。
  • 为了让本地终端出现,需要使用Android界面重启我们的Raspberry Pi。要调出电源选项菜单,您需要按键盘上的F5键。进入电源菜单后,点击 “重新启动 “按钮。

修复android,wifi不能连接和时钟错误

WIFI联网会出现感叹号,这是因为系统自带的网络测试时国外的,所以连不上,要解决这个问题,打开开发选项后用adb命令解决。

  • 在安卓设备的桌面上,从最下面的三个应用中点击并向上拖动,弹出应用库。
  • 选择“终端”。
  • 打开后,输入指令:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    # 指定国内服务
    settings delete global captive_portal_https_url
    settings delete global captive_portal_http_url
    settings put global captive_portal_https_url https://connect.rom.miui.com/generate_204
    settings put global captive_portal_http_url http://connect.rom.miui.com/generate_204

    # 时钟源
    setprop persist.sys.timezone Asia/Shanghai
    settings put global ntp_server ntp1.aliyun.com
  • 经过上述操作,wifi能够正确连接了