28

Android 虚拟机可以这么用了 ?

 4 years ago
source link: https://luyao.tech/archives/embedded-emulator
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

说实话,我其实很少使用 Android Studio 自带的 Emulator 。一来巨慢(电脑太渣),二来 IDE 全屏的时候不能直接查看,还得快捷键切来切去,甚是麻烦。

在最新的 Android Studio 4.1 Canary 8 中,直接内置了 Emulator 。你可以在 IDE 内部直接运行 Emulator,而不再是一个单独的应用了。来一张官网上的图片给你感受一下。

yInIbiy.gif

不得不说,Android Studio 团队最近可谓诚意满满,之前刚刚放出了 Database Inspector 功能。我在之前的推文 数据库还可以这么查看 中也介绍过。

另外,最新的 Database Inspector 已经支持了 Live Update 功能,当你在应用中对数据库数据进行改变时,视图工具中会自动展示数据修改,而不用再手动刷新了。

下面简单介绍一下 内置 Emulator 的使用方法。

使用方式

File > Settings > Tools > Emulator (or Android Studio > Preferences > Tools > Emulator on macOS)

m6JjaqE.png!web

勾选右侧的 Launch in a Tool Window

然后和往常一样运行应用就可以了。你可以先通过 AVD Manager 开启虚拟机,或者指定虚拟机直接运行 App 。

限制

内置虚拟机支持的扩展功能很少,目前只有关机、音量、屏幕旋转、返回键、Home 键、截图等。如果你的应用强烈依赖各种扩展功能,还是使用之前的方式吧。

体验

我在我的开源项目 Wanandroid 上体验了一把,大概就长这样。

bqumErV.png!web

恩,真香。

我还是使用真机吧。逃~

题外话

不知道你有没有运行过我之前版本的 Wanandroid,丑的我自己都不忍直视。在最新一次提交中,我升级到了 MDC 1.1.0 ,就是这个东西:

implementation ‘com.google.android.material:material:1.1.0’

MDC 1.1.0 带来了 Material Theming,新的组件,暗黑模式支持等等。我将原本应用中的 AppCompat 系主题替换成了 MaterialComponents 系,并替换了一部分组件,不得不说,的确美观了很多。大家也可以尝试一下。

具体修改可查看我的最近一次提交:

https://github.com/lulululbj/wanandroid/commit/fc900ab20b07c2bf4b266fae4ab931f1c6aef01e

官方也有一篇文章专门介绍了 MDC ,地址如下:

https://medium.com/androiddevelopers/migrating-to-material-components-for-android-ec6757795351

今天的文章就到这里了,我是一直坚持原创的秉心说,更多最新 Android 动态,扫码关注我的公众号吧 !

qYRz2q6.png!web


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK