我了解如何使用Intents与系统/其他应用程序进行通信.我了解如何在同一个应用程序中使用Intent.我也了解如何使用Otto在同一个App中进行通信.
使用Otto vs. Intents在我的活动/服务之间进行交流的Pro/Cons是什么?
我按照这个开发人员教程,按照预期在我的应用程序中运行Geofencing.
发生地理围栏转换时会发出通知,来自IntentService:
@Override
protected void onHandleIntent(Intent intent) {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
...
sendNotification(geofenceTransitionDetails);
}
private void sendNotification(String notificationDetails) {
// Create an explicit content Intent that starts the main Activity.
Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
// Construct a task stack.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Add the main Activity to the task stack as the parent.
stackBuilder.addParentStack(MainActivity.class);
// Push the content Intent onto the stack.
stackBuilder.addNextIntent(notificationIntent);
// Get a PendingIntent containing the entire back …Run Code Online (Sandbox Code Playgroud) android android-notifications intentservice android-alertdialog android-geofence