我正在使用此代码检索所有联系人姓名和电话号码:
String[] projection = new String[]
{
People.NAME,
People.NUMBER
};
Cursor c = ctx.getContentResolver().query(People.CONTENT_URI, projection, null, null, People.NAME + " ASC");
c.moveToFirst();
int nameCol = c.getColumnIndex(People.NAME);
int numCol = c.getColumnIndex(People.NUMBER);
int nContacts = c.getCount();
do
{
// Do something
} while(c.moveToNext());
Run Code Online (Sandbox Code Playgroud)
但是,这只会返回每个联系人的主号码,但我也想获得次要号码.我怎样才能做到这一点?
昨天我的Nexus 5收到了Android MNC版本的更新6.0 - Marshmallow.从那时起,扫描设备中可用网络的操作就会停止接收列表,在这种情况下,结果列表的大小为0,即使在Wifi系统设置中列出了10多个Wifi网络.
通常的代码是:SCAN_RESULTS_AVAILABLE_ACTION在Receiver中注册并等待事件,如下所示:
// Register the Receiver in some part os fragment...
getActivity().registerReceiver(wifiListener, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
wifiManager.startScan();
// Inside the receiver:
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
List<ScanResult> results = wifiManager.getScanResults();
// the result.size() is 0 after update to Android v6.0, same code working in older devices.
Run Code Online (Sandbox Code Playgroud)
我搜索了有关此主题的API主题的更改,但我没有看到此功能的任何重大更改.
有没有人注意到这个?API中是新的东西还是仅仅是一个孤立的案例?