|
1 package org.gege.caldavsyncadapter.syncadapter.notifications; |
|
2 |
|
3 import org.gege.caldavsyncadapter.R; |
|
4 |
|
5 import android.app.NotificationManager; |
|
6 //import android.app.PendingIntent; |
|
7 import android.content.Context; |
|
8 //import android.content.Intent; |
|
9 import android.support.v4.app.NotificationCompat; |
|
10 //import android.support.v4.app.TaskStackBuilder; |
|
11 |
|
12 public class NotificationsHelper { |
|
13 |
|
14 /*static SyncLog currentSyncLog = new SyncLog(); |
|
15 doesn't exist */ |
|
16 |
|
17 public static void signalSyncErrors(Context context, String title, String text) { |
|
18 NotificationCompat.Builder mBuilder = |
|
19 new NotificationCompat.Builder(context) |
|
20 .setSmallIcon(R.drawable.icon) |
|
21 .setContentTitle(title) |
|
22 .setContentText(text); |
|
23 |
|
24 // Creates an explicit intent for an Activity in your app |
|
25 /* Intent resultIntent = new Intent(context, SyncStatusReportActivity.class); |
|
26 |
|
27 // The stack builder object will contain an artificial back stack for the |
|
28 // started Activity. |
|
29 // This ensures that navigating backward from the Activity leads out of |
|
30 // your application to the Home screen. |
|
31 TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); |
|
32 // Adds the back stack for the Intent (but not the Intent itself) |
|
33 stackBuilder.addParentStack(SyncStatusReportActivity.class); |
|
34 // Adds the Intent that starts the Activity to the top of the stack |
|
35 stackBuilder.addNextIntent(resultIntent); |
|
36 PendingIntent resultPendingIntent = |
|
37 stackBuilder.getPendingIntent( |
|
38 0, |
|
39 PendingIntent.FLAG_UPDATE_CURRENT |
|
40 ); |
|
41 mBuilder.setContentIntent(resultPendingIntent); |
|
42 */ |
|
43 |
|
44 NotificationManager mNotificationManager = |
|
45 (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |
|
46 |
|
47 // mId allows you to update the notification later on. |
|
48 int mId = 0; |
|
49 mNotificationManager.notify(mId, mBuilder.build()); |
|
50 } |
|
51 |
|
52 /*public static SyncLog getCurrentSyncLog() { |
|
53 return currentSyncLog; |
|
54 }*/ |
|
55 |
|
56 } |