Added an if block to run the right notification methods

closes #21

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-04-28 20:17:49 -04:00
parent 110f60341c
commit 663f3fe471

View File

@@ -11,6 +11,7 @@ import java.io.IOException;
import org.apache.http.client.ClientProtocolException; import org.apache.http.client.ClientProtocolException;
import android.app.Notification; import android.app.Notification;
import android.app.Notification.Builder;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.Service; import android.app.Service;
@@ -64,23 +65,24 @@ public class ReportPostingService extends Service {
Context context = this.getApplicationContext(); Context context = this.getApplicationContext();
mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(android.R.drawable.stat_sys_upload, getText(R.string.sending) , System.currentTimeMillis());
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.setLatestEventInfo(context, getText(R.string.sending_report), getText(R.string.sending), PendingIntent.getActivity(context, 0, null, 0));
mNotificationManager.notify(NOTIFICATION_ID, notification);
/* /*
* for api 11+ * Use the appropriate notificafation methods
*/ */
// Builder builder = new Notification.Builder(context) if(Integer.valueOf(android.os.Build.VERSION.SDK_INT) > 11){
// .setContentTitle(getText(R.string.sending)) Builder builder = new Notification.Builder(context)
// .setContentText(getText(R.string.sending_report)) .setContentTitle(getText(R.string.sending))
// .setTicker(getText(R.string.sending)) .setContentText(getText(R.string.sending_report))
// .setOngoing(true) .setTicker(getText(R.string.sending))
// .setSmallIcon(android.R.drawable.stat_sys_upload) .setOngoing(true)
// .setWhen(System.currentTimeMillis()); .setSmallIcon(android.R.drawable.stat_sys_upload)
mNotificationManager.notify(NOTIFICATION_ID, notification); .setWhen(System.currentTimeMillis());
mNotificationManager.notify(NOTIFICATION_ID, builder.getNotification());
} else {
Notification notification = new Notification(android.R.drawable.stat_sys_upload, getText(R.string.sending) , System.currentTimeMillis());
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.setLatestEventInfo(context, getText(R.string.sending_report), getText(R.string.sending), PendingIntent.getActivity(context, 0, null, 0));
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
super.onCreate(); super.onCreate();
} }
@@ -100,6 +102,7 @@ public class ReportPostingService extends Service {
* (non-Javadoc) * (non-Javadoc)
* @see android.app.Service#onStart(android.content.Intent, int) * @see android.app.Service#onStart(android.content.Intent, int)
*/ */
@SuppressWarnings("deprecation")
@Override @Override
public void onStart(Intent intent, int startId) { public void onStart(Intent intent, int startId) {
mStartId = startId; mStartId = startId;