2012-08-27 57 views
0

如何以編程方式通知設備在Android GPS中發生錯誤的方向。我有設置default.I的路徑設置的路徑是這樣的:如何在設備不在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);` 

雖然移動從一個點到另一個設備只能移動到該路徑。當用戶移出該路徑時(例如向右或向左指100米),它應該通知用戶。

先謝謝您。

+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()中使用它;有ü可以處理,當你在一個很好的方法還是不行。(有ü可以檢查的經度和緯度。)

1

我想這個鏈接可以幫助你

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

將其粘貼到不帶引號的地址中。

相關問題