0

In my application, How can I detect when GPS is turn on by other application installed on device?

Kara
  • 5,996
  • 16
  • 49
  • 56
Adri
  • 375
  • 3
  • 6

2 Answers2

0

You can easily check what app is able to get a location data by reading apps permissions with PackageManager class.

http://developer.android.com/reference/android/content/pm/PackageManager.html

piotrpo
  • 12,020
  • 7
  • 39
  • 58
0

steps -

  1. Create services running in backgroud
  2. You require following permission in Manifest file too -

    android.permission.ACCESS_FINE_LOCATION

  3. write code

    final LocationManager manager = (LocationManager)context.getSystemService (Context.LOCATION_SERVICE );

    if ( !manager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) Toast.makeText(context, "GPS is disable!", Toast.LENGTH_LONG).show(); else Toast.makeText(context, "GPS is Enable!", Toast.LENGTH_LONG).show();

  4. Or simply you can check

    LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE ); boolean statusOfGPS = manager.isProviderEnabled(LocationManager.GPS_PROVIDER);

  5. run your services continuous to monitor connection

Rakesh
  • 2,552
  • 28
  • 27