GPS를 사용/추적하지만 위치 요청이 켜진 경우뿐만 아니라 GPS 사용을 추적하는 앱을 개발 중입니다.의도를 브로드 캐스트하는 앱 이름 받기
연구를 마친 후 내 매니페스트에서 다음 코드를 사용하여이를 보관할 수 있음을 알게되었습니다.
<receiver android:name=".triggers.TriggerGPS">
<intent-filter>
<action android:name="android.location.GPS_ENABLED_CHANGE" />
</intent-filter>
</receiver>
이 앱이 GPS 좌표를 요청할 때마다 TriggerGPS 클래스가 호출됩니다.
public class TriggerGPS extends BroadcastReceiver {
Calendar c = Calendar.getInstance();
@Override
public void onReceive(Context context, Intent intent) {
String currentDatetime = c.get(Calendar.DAY_OF_MONTH) + "/" + c.get(Calendar.MONTH) + "/" +
c.get(Calendar.YEAR) + " " + c.get(Calendar.HOUR_OF_DAY) + ":" +
c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND);
Log.d("---------log--------", "Intent (" + intent.getAction() + ") GPS Status onReceive : " + currentDatetime);
}
}
그러나 각 응용 프로그램을 나타내는 보고서를 작성해야 내 앱이 GPS를 사용하고 몇 번이나 앱 드 하루 좌표를 얻기 위해 GPS를 사용했다.
여기서 문제는 이벤트를 브로드 캐스팅하는 앱 이름을 얻는 방법을 알아낼 수 없다는 것입니다.
할 수있는 방법이 있습니까?
감사합니다.
그러나 "android.location.GPS_ENABLED_CHANGE"수신은 GPS의 변경 상태를 켜기/끄기 사이에서 추적하지 않습니다. 그것은 GPS 좌표 요청을 추적하고 있습니다. –
하지만 당신이 한 말을 이해합니다. 도와 줘서 고마워! : D –
나는 이해했다. GPS가 앱 (모든 앱)에 의해 사용되었다는 사실을 알게 된 다른 것이 PASSIVE_PROVIDER를 사용하고있었습니다. https://developer.android.com/reference/android/location/LocationManager.html#PASSIVE_PROVIDER –