2

we are creating a library so we have to not using this permissions:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

last thing i was reached,it was using bts towers,but it seems getting information from bts towers requires ACCESS_COARSE_UPDATES.

so what we can to determine user's city or priviance

get bts info:

 TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE); 

 List<NeighboringCellInfo> NeighboringList = telephonyManager.getNeighboringCellInfo(); 

 ArrayList<bts> btss=new ArrayList<>();
 for (int i = 0; i < NeighboringList.size(); i++) { 
      btss.add(new bts(NeighboringList.get(i).getCid(),NeighboringList.get(i).getLac())); 
 } 
Slava Vedenin
  • 58,326
  • 13
  • 40
  • 59
Enakhi
  • 1,143
  • 10
  • 16
  • Make it a AAR library project so the permissions will be handled correctly: http://stackoverflow.com/questions/29664359/putting-permissions-to-manifest-of-android-aar-library-project – Morrison Chang Dec 20 '15 at 03:44
  • everyone who is using our library they don't want to use those permissions.we have to get user's city without using any permission. – Enakhi Dec 20 '15 at 03:51
  • APIs which access possible location information should be protected by the manifest permissions, as location is considered sensitive information about the user. Alternatively since you are looking for city/province level data you could try IP location based lookup but that would require INTERNET permission and a external server to get the external IP. See: http://stackoverflow.com/q/6077555/295004 and http://stackoverflow.com/q/274308/295004 but realize that what you are getting is the location of the NAT not the mobile device. – Morrison Chang Dec 20 '15 at 04:44
  • we also test the IP solution,but it's not true always,some ISPs provide internet to other cities and when we get the information,wrong city is given to us. – Enakhi Dec 20 '15 at 12:59

0 Answers0