相关疑难解决方法(0)

阅读android中所有联系人的电话号码

我正在使用此代码检索所有联系人姓名和电话号码:

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)

但是,这只会返回每个联系人的主号码,但我也想获得次要号码.我怎样才能做到这一点?

android contacts phone-number android-contacts

68
推荐指数
6
解决办法
14万
查看次数

Android 6.0中的SCAN_RESULTS_AVAILABLE_ACTION返回空列表

昨天我的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中是新的东西还是仅仅是一个孤立的案例?

android android-wifi android-6.0-marshmallow

45
推荐指数
4
解决办法
3万
查看次数