简体   繁体   English

Android 模拟器中缺少小部件预览应用程序

[英]Widget Preview app missing from Android emulator

This https://developer.android.com/guide/topics/appwidgets/#preview says这个https://developer.android.com/guide/topics/appwidgets/#preview

To help create a preview image for your app widget (to specify in the previewImage field), the Android emulator includes an application called "Widget Preview."为了帮助为您的应用小部件创建预览图像(在 previewImage 字段中指定),Android 模拟器包含一个名为“小部件预览”的应用程序。 To create a preview image, launch this application, select the app widget for your application and set it up how you'd like your preview image to appear, then save it and place it in your application's drawable resources.要创建预览图像,请启动此应用程序,为您的应用程序选择应用程序小部件并设置您希望预览图像的显示方式,然后将其保存并放置在应用程序的可绘制资源中。

I can't find this application on the latest Android system image, Android Oreo (8.1) API 27我在最新的 Android 系统映像 Android Oreo (8.1) API 27 上找不到此应用程序

This question has been asked and answered here, Widget preview image , but the application is missing.此问题已在Widget preview image 中提出并回答,但缺少应用程序。

So how do I generate a preview image?那么如何生成预览图像呢?

在此处输入图片说明 在此处输入图片说明

The Widget Preview app will only show up when running an older version of Android on an emulator (API 26 or lower). Widget Preview 应用仅在模拟器(API 26 或更低版本)上运行旧版 Android 时才会显示。

If the Widget Preview isn't showing up on your emulator, you need to create a new Virtual Device with a lower API in Android Studio:如果 Widget Preview 未显示在您的模拟器上,您需要在 Android Studio 中创建一个具有较低 API 的新虚拟设备:

1) Tools>AVD Manager>Create Virtual Device... 1) 工具>AVD 管理器>创建虚拟设备...

2) Select the device you'd like to use, click "Next" 2) 选择您要使用的设备,点击“下一步”

3) In the next window, select Nougat, API Level 25. You may need to download it if you've never used it before. 3) 在下一个窗口中,选择 Nougat,API Level 25。如果您以前从未使用过它,则可能需要下载它。 Click "Next", then "Finish"单击“下一步”,然后单击“完成”

4) Run the app on the new virtual device, and search for the Widget Preview again 4) 在新的虚拟设备上运行该应用程序,并再次搜索 Widget Preview

After the preview has been created, the emulator gives you the option of emailing it so you can save it locally and later to the drawables folder of your project.创建预览后,模拟器会为您提供通过电子邮件发送的选项,以便您可以将其保存在本地,然后保存到项目的 drawables 文件夹中。

Hope that solves it for you too!希望也能为你解决!

未来的读者,我通过使用较旧的 android 版本系统映像解决了这个问题。

Long press on App Icon in emulator .长按模拟器中的应用程序图标。 You will see an option of Widgets, Click on Widget and drop on Home screen and Widget created.您将看到一个小工具选项,单击小工具并拖放到主屏幕上并创建小工具。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM