我有座標列表(30+對經度,緯度),我的任務是:發送GPS通知,到處
我應該創建其發送通知(在狀態欄),以一個Android應用程序用戶如果他/她在我的列表中包含的30個位置之一。通知部分已準備就緒,我可以在一個活動中做到這一點(遍歷列表,如果座標相同,然後發送通知,但我怎麼能做到這一點所有活動,以及應用程序在緩存中的時間,但不開?謝謝
Intent intent = new Intent(AGPS.this, SecondClass.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(AnotherGPS.this);
stackBuilder.addParentStack(SecondClass.class);
stackBuilder.addNextIntent(intent);
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent
.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder =
(NotificationCompat.Builder) new NotificationCompat.Builder(AnotherGPS.this)
.setSmallIcon(R.drawable.cam_icon)
.setContentTitle("My notification")
.setContentText("content of notification")
.setContentIntent(pendingIntent);
NotificationManager NM = (NotificationManager) getSystemService(Context
.NOTIFICATION_SERVICE);
NM.notify(0, mBuilder.build());
感謝您的快速答覆。我會檢查出來的! –