0

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

Kara
  • 6,115
  • 16
  • 50
  • 57
Adri
  • 385
  • 4
  • 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,398
  • 7
  • 42
  • 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,732
  • 29
  • 28