2012-08-27 1 views
0

Android GPS에서 기기가 프로그램 방식으로 잘못된 방향으로 진행될 때이를 알리는 방법.기기가 Android에서 경로 밖에있을 때 알림을받는 방법은 무엇입니까?

final Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://maps.google.com/maps?" + "saddr="+ 12.756742 + "," + 76.67523465 + "&daddr=" + 12.64345213 + "," + 76.875432)); 
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity"); 
startActivity(intent);` 

하는 한 지점에서 다른 장치를 이동하면 해당 경로에만 이동해야하지만 : 나는 default.I 설정 경로는 다음과 같이 경로를 설정합니다. 사용자가 해당 경로에서 벗어나면 (오른쪽 또는 왼쪽으로 100m) 사용자에게 알려야합니다.

미리 감사드립니다.

+0

무엇을 시도 했습니까? 일정 간격으로 GPS를 확인하기 위해 구성 요소를 만들려고 했습니까? – RvdK

답변

0
  NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 

    // Create Notifcation 
    Notification notification = new Notification(R.drawable.ic_launcher, 
      "A new notification", System.currentTimeMillis()); 

    // Cancel the notification after its selected 
    notification.flags |= Notification.FLAG_AUTO_CANCEL; 
    // 

    // Specify the called Activity 
    Intent intent = new Intent(this, ur_activity.class); 

    PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0); 
    notification.setLatestEventInfo(this, "your tittle", 
      "ur notifi text", activity); 
    notificationManager.notify(0, notification); 

그리고 이것을 onLocationChanged(); 이 u는 당신이 좋은 방법으로 또는하지 않을 때 처리 할 수 ​​있습니다. (이 유 위도와 경도를 확인할 수 있습니다.)

1

를 나는이 링크가 당신에게 도움이 될 것 같아요

"http://developer.android.com /reference/android/location/LocationManager.html#addProximityAlert(double, double, float, long, android.app.PendingIntent) "

따옴표없이 주소에 붙여 넣습니다.

관련 문제