Updated the exception reporting service to work on api 1+

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-04-23 12:19:31 -04:00
parent e841daa615
commit 110f60341c
2 changed files with 21 additions and 9 deletions

View File

@@ -120,6 +120,7 @@ public class ExceptionHandler implements UncaughtExceptionHandler, Runnable {
* displays an notification in the status bar, letting the user know that there was an issue * displays an notification in the status bar, letting the user know that there was an issue
* @param generatedReportIntent * @param generatedReportIntent
*/ */
@SuppressWarnings("deprecation")
private void displayNotification(Intent generatedReportIntent) { private void displayNotification(Intent generatedReportIntent) {
Log.i(TAG, "displayNotification"); Log.i(TAG, "displayNotification");
Context context = mContext.getApplicationContext(); Context context = mContext.getApplicationContext();

View File

@@ -11,8 +11,8 @@ 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.Service; import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -58,18 +58,29 @@ public class ReportPostingService extends Service {
* (non-Javadoc) * (non-Javadoc)
* @see android.app.Service#onCreate() * @see android.app.Service#onCreate()
*/ */
@SuppressWarnings("deprecation")
@Override @Override
public void onCreate() { public void onCreate() {
Context context = this.getApplicationContext(); Context context = this.getApplicationContext();
mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Builder builder = new Notification.Builder(context)
.setContentTitle(getText(R.string.sending))
.setContentText(getText(R.string.sending_report)) Notification notification = new Notification(android.R.drawable.stat_sys_upload, getText(R.string.sending) , System.currentTimeMillis());
.setTicker(getText(R.string.sending)) notification.flags |= Notification.FLAG_ONGOING_EVENT;
.setOngoing(true) notification.setLatestEventInfo(context, getText(R.string.sending_report), getText(R.string.sending), PendingIntent.getActivity(context, 0, null, 0));
.setSmallIcon(android.R.drawable.stat_sys_upload) mNotificationManager.notify(NOTIFICATION_ID, notification);
.setWhen(System.currentTimeMillis());
mNotificationManager.notify(NOTIFICATION_ID, builder.getNotification()); /*
* for api 11+
*/
// Builder builder = new Notification.Builder(context)
// .setContentTitle(getText(R.string.sending))
// .setContentText(getText(R.string.sending_report))
// .setTicker(getText(R.string.sending))
// .setOngoing(true)
// .setSmallIcon(android.R.drawable.stat_sys_upload)
// .setWhen(System.currentTimeMillis());
mNotificationManager.notify(NOTIFICATION_ID, notification);
super.onCreate(); super.onCreate();
} }