我正在尝试使用此内容提供程序获取双SIM卡设备的SimInfo
public static List<SimInfo> getSIMInfo(Context context) {
List<SimInfo> simInfoList = new ArrayList<>();
Uri URI_TELEPHONY = Uri.parse("content://telephony/siminfo/");
Cursor c = context.getContentResolver().query(URI_TELEPHONY, null, "slot>=0", null, null);
if (c!=null && c.moveToFirst()) {
do {
int id = c.getInt(c.getColumnIndex("_id"));
int slot = c.getInt(c.getColumnIndex("slot"));
String display_name = c.getString(c.getColumnIndex("display_name"));
String icc_id = c.getString(c.getColumnIndex("icc_id"));
String number=c.getString(c.getColumnIndex("number"));
SimInfo simInfo = new SimInfo(id, display_name, icc_id, slot, number);
Log.d("apipas_sim_info", simInfo.toString());
simInfoList.add(simInfo);
} while (c.moveToNext());
c.close();
}
return simInfoList;
}
它正在API 17上运行,但对于API> = 22,Cursor返回null。