Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
  2. if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
  3. ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
  4. // TODO: Consider calling
  5. // ActivityCompat#requestPermissions
  6. // here to request the missing permissions, and then overriding
  7. // public void onRequestPermissionsResult(int requestCode, String[] permissions,
  8. // int[] grantResults)
  9. // to handle the case where the user grants the permission. See the documentation
  10. // for ActivityCompat#requestPermissions for more details.
  11.  
  12. }
  13.  
  14. GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager.getCellLocation();
  15. String networkOperator = telephonyManager.getNetworkOperator();
  16. String networOperatorName = telephonyManager.getNetworkOperatorName();
  17. String networkTyInfo = String.valueOf(telephonyManager.getNetworkType());
  18.  
  19.  
  20. int mnc = 0, mcc = 0;
  21. if (!TextUtils.isEmpty(networkOperator)) {
  22. mcc = Integer.parseInt(networkOperator.substring(0, 3));
  23. mnc = Integer.parseInt(networkOperator.substring(3));
  24. }
  25. int cid =0;
  26. int lac = 0;
  27. if (cellLocation != null) {
  28. cid = cellLocation.getCid();
  29. lac = cellLocation.getLac();
  30. }
  31.  
  32. GSMValues gsmValues =
  33. new GSMValues(
  34. String.valueOf(lac),
  35. String.valueOf(mcc),
  36. String.valueOf(mnc),
  37. String.valueOf(cid),
  38. String.valueOf(0),
  39. networkTyInfo,
  40. signalStrength,
  41. networOperatorName
  42. );
  43. // db = new DatabaseHelper(getApplicationContext());
  44.  
  45. // db.StoreLocations(gsmValues);
  46.  
  47. TelephonyManager TM = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
  48. List<NeighboringCellInfo> neighboringCellInfoList = TM.getNeighboringCellInfo();
  49.  
  50. if(neighboringCellInfoList != null){
  51. // iterate the list
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement