src/org/gege/caldavsyncadapter/syncadapter/notifications/NotificationsHelper.java

changeset 0
fb9019fb1bf7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/org/gege/caldavsyncadapter/syncadapter/notifications/NotificationsHelper.java	Tue Feb 10 18:12:00 2015 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +package org.gege.caldavsyncadapter.syncadapter.notifications;
     1.5 +
     1.6 +import org.gege.caldavsyncadapter.R;
     1.7 +
     1.8 +import android.app.NotificationManager;
     1.9 +//import android.app.PendingIntent;
    1.10 +import android.content.Context;
    1.11 +//import android.content.Intent;
    1.12 +import android.support.v4.app.NotificationCompat;
    1.13 +//import android.support.v4.app.TaskStackBuilder;
    1.14 +
    1.15 +public class NotificationsHelper {
    1.16 +
    1.17 +	/*static SyncLog currentSyncLog = new SyncLog();
    1.18 +	 doesn't exist */
    1.19 +	
    1.20 +	public static void signalSyncErrors(Context context, String title, String text) {
    1.21 +		NotificationCompat.Builder mBuilder =
    1.22 +		        new NotificationCompat.Builder(context)
    1.23 +		        .setSmallIcon(R.drawable.icon)
    1.24 +		        .setContentTitle(title)
    1.25 +		        .setContentText(text);
    1.26 +		
    1.27 +		// Creates an explicit intent for an Activity in your app
    1.28 +/*		Intent resultIntent = new Intent(context, SyncStatusReportActivity.class);
    1.29 +
    1.30 +		// The stack builder object will contain an artificial back stack for the
    1.31 +		// started Activity.
    1.32 +		// This ensures that navigating backward from the Activity leads out of
    1.33 +		// your application to the Home screen.
    1.34 +		TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    1.35 +		// Adds the back stack for the Intent (but not the Intent itself)
    1.36 +		stackBuilder.addParentStack(SyncStatusReportActivity.class);
    1.37 +		// Adds the Intent that starts the Activity to the top of the stack
    1.38 +		stackBuilder.addNextIntent(resultIntent);
    1.39 +		PendingIntent resultPendingIntent =
    1.40 +		        stackBuilder.getPendingIntent(
    1.41 +		            0,
    1.42 +		            PendingIntent.FLAG_UPDATE_CURRENT
    1.43 +		        );
    1.44 +		mBuilder.setContentIntent(resultPendingIntent);
    1.45 +*/		
    1.46 +		
    1.47 +		NotificationManager mNotificationManager =
    1.48 +			    (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    1.49 +			
    1.50 +			// mId allows you to update the notification later on.
    1.51 +		int mId = 0;
    1.52 +		mNotificationManager.notify(mId, mBuilder.build());
    1.53 +	}
    1.54 +
    1.55 +	/*public static SyncLog getCurrentSyncLog() {
    1.56 +		return currentSyncLog;
    1.57 +	}*/
    1.58 +	
    1.59 +}

mercurial