我在Android应用程序中尝试使用WifiNetworkSuggestion打开意向时遇到了一个问题。每当我打电话给
startOperation()
函数,我得到一个带有以下错误消息的Resources$NotFoundException:
Drawable com.android.settings:drawable/ic_wifi_signal_0 with resource ID #0x7f080952
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f040875 a=-1}, theme={InheritanceMap=[id=0x7f13059acom.android.settings:style/Theme.Panel, id=0x1030403android:style/Theme.DeviceDefault.Settings.Dialog, id=0x1030407android:style/Theme.DeviceDefault.Settings.DialogBase, id=0x1030438android:style/Theme.Material.Light.BaseDialog, id=0x1030237android:style/Theme.Material.Light, id=0x103000candroid:style/Theme.Light, id=0x1030005android:style/Theme], Themes=[com.android.settings:style/Theme.Panel, forced, android:style/Theme.DeviceDefault.Light.DarkActionBar, forced]}
它似乎与可提取的资源有关
ic_wifi_signal_
中的0
com.android.settings
包,但我无法解决它。该错误提到使用特定TypedValue和主题信息进行属性解析失败。
我正在使用
startOperation()
通过
ACTION_WIFI_ADD_NETWORKS
意图我使用的代码片段如下:
科特林
复制代码
@RequiresApi(Build.VERSION_CODES.R)
fun startOperation() {
val suggestions = ArrayList<WifiNetworkSuggestion>()
suggestions.add(WifiNetworkSuggestion.Builder().setSsid(ifeRougeWifiSsid).build())
suggestions.add(WifiNetworkSuggestion.Builder().setSsid(ifeAcWifiSsid).build())
val bundle = Bundle()
bundle.putParcelableArrayList(EXTRA_WIFI_NETWORK_LIST, suggestions)
val intent = Intent(ACTION_WIFI_ADD_NETWORKS)
intent.putExtras(bundle)
launcher.launch(intent)
}
我已经检查了
ifeRougeWifiSsid
和
ifeAcWifiSsid
变量已正确初始化。
如果能就如何解决这一问题提供任何见解或建议,我将不胜感激。非常感谢。