2017-05-10 1 views
3

J'ai une application android qui récupère des informations sur les tours de téléphonie cellulaire. J'utilise getAllCellInfo() pour récupérer les informations d'une cellule primaire et des cellules voisines. J'ai inclus l'autorisation ACCESS_COARSE_LOCATION à manifest.xml et faire une requête pour l'autorisation en cours d'exécution. Cela fonctionne dans d'autres téléphones mais dans Huawei Honor 7, la fonction renvoie une liste vide.

Mon code:
enter image description here
CatLog: enter image description heregetAllCellInfo() retourne une liste vide dans Huawei Honor 7

J'ai vérifié d'autres questions aux gens: getAllCellInfo returns null in android 4.2.1 et Android getAllCellInfo() returns null.

d'une question, je pensais que pour les téléphones Huawei, ils ne prennent pas en charge getAllCellInfo() jusqu'à ce que j'ai installé Network Cell Info Lite et NetMonster, et il semble que les applications peuvent récupérer les informations de cellule Huawei Honor 7:

réseau infos cellule Lite
enter image description here
NetMonster
enter image description here

toute personne a des informations à ce sujet?

Répondre

2

Pour un peu de travail autour quand il n'y a pas de cellule dans getAllCellInfo(), j'utilise getCellLocation() pour obtenir le primaryCellId et trackingAreaCode comme ceci:

Log.d(TAG, "updateCurrentCell: can't find any cells with getAllCellInfo"); 
    CellLocation primaryLocation = telephonyManager.getCellLocation(); 
    if (primaryLocation != null) { 
     int primaryCellId = Integer.parseInt(primaryLocation.toString().split(",")[1]); 
     int trackingAreaCode = Integer.parseInt(primaryLocation.toString().split(",")[0].replace("[", "")); 
    } else { 
     Log.d(TAG, "updateCurrentCell: not even with getCellLocation"); 
    }