如何判断一个街景启动街景意图之前存在街景、意图、如何判断、存在

2023-09-08 08:30:38 作者:成熟就是把哭声调成无声

启动一个街景意图为一个位置并不保证一个街景存在该位置。如果街景不存在时,用户只看到黑屏该旋转。有没有一种方法以编程方式检查是否启动街景意图之前存在?

Launching a Streetview intent for a location doesn't guarantee that a Streetview exists for that location. If the Streetview doesn't exist, the user just sees a black screen that spins. Is there a way to programmatically check if it exists before launching the Streetview intent?

推荐答案

使用PackageManager和 queryIntentActivities() 您的意图。如果你获得了0匹配的活动清单,你什么都不知道设备将处理您的请求。

Use PackageManager and queryIntentActivities() with your Intent. If you get back a list of 0 matching activities, you know nothing on the device will handle your request.