如何检测的Andr​​oid市场对设备的存在?存在、设备、市场、Andr

2023-09-05 09:37:36 作者:年华似水终老去゛

一些Android设备没有Android的市场,如韩国等。

是否有可能在运行时检测Android电子市场的存在?

我知道我可以尝试先打开市场URI来看看是否有任何抛出的异常。但我不认为这是一个明智的做法。

解决方案   

我知道我可以尝试打开市场的URI   首先,以查看是否有任何异常   抛出。

创建 ACTION_VIEW 意图为市场乌里 ,然后用 PackageManager queryIntentActivities()来看看你得到任何东西。如果返回一个空的列表,你什么都不知道在设备上处理市场乌里值。

Some Android devices don't have Android Market, like Korea, etc.

Is it possible to detect the existence of Android Market at runtime?

I know I can try to open a market uri first to see if there is any exception thrown. But I don't think this is a wise approach.

解决方案

I know I can try to open a market uri first to see if there is any exception thrown.

Create the ACTION_VIEW Intent for the Market Uri, then use PackageManager and queryIntentActivities() to see if you get anything back. If that returns an empty list, you know nothing on the device handles Market Uri values.