Java Code Examples for android.app.IntentService

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Synodroid, under directory /src/com/bigpupdev/synodroid/utils/.

Source file: ServiceHelper.java

  19 
vote

public static Notification getNotificationProgress(IntentService self,String text,int curProgress,int ID,int icon){
  final Notification notification=new Notification(R.drawable.status_icon,text,System.currentTimeMillis());
  notification.flags=notification.flags | Notification.FLAG_ONGOING_EVENT;
  notification.contentView=new RemoteViews(self.getApplicationContext().getPackageName(),R.layout.notification);
  notification.contentView.setImageViewResource(R.id.status_icon,icon);
  notification.contentView.setTextViewText(R.id.status_text,text);
  notification.contentView.setProgressBar(R.id.status_progress,100,curProgress,false);
  Intent pending=new Intent(self,HomeActivity.class);
  pending.putExtra("com.bigpupdev.synodroid.notifyId",ID);
  notification.contentIntent=PendingIntent.getActivity(self,1,pending,0);
  final NotificationManager notificationManager=(NotificationManager)self.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
  notificationManager.notify(ID,notification);
  return notification;
}
 

Example 2

From project Synodroid, under directory /src/com/bigpupdev/synodroid/utils/.

Source file: ServiceHelper.java

  19 
vote

public static void showNotificationError(IntentService self,String action,String text,int icon){
  final Notification notification=new Notification(R.drawable.status_icon,text,System.currentTimeMillis());
  notification.flags=notification.flags | Notification.FLAG_AUTO_CANCEL;
  notification.contentView=new RemoteViews(self.getApplicationContext().getPackageName(),R.layout.notification_error);
  notification.contentView.setImageViewResource(R.id.status_icon,icon);
  notification.contentView.setTextViewText(R.id.status_text,action);
  notification.contentView.setTextViewText(R.id.status_cancel,text);
  Intent pending=new Intent(self,HomeActivity.class);
  pending.putExtra("com.bigpupdev.synodroid.notifyId",ERROR_ID);
  notification.contentIntent=PendingIntent.getActivity(self,1,pending,0);
  final NotificationManager notificationManager=(NotificationManager)self.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
  notificationManager.notify(ERROR_ID,notification);
}
 

Example 3

From project Synodroid, under directory /src/com/bigpupdev/synodroid/utils/.

Source file: ServiceHelper.java

  19 
vote

public static void showNotificationInfo(IntentService self,String action,String text,int icon){
  final Notification notification=new Notification(R.drawable.status_icon,text,System.currentTimeMillis());
  notification.flags=notification.flags | Notification.FLAG_AUTO_CANCEL;
  notification.contentView=new RemoteViews(self.getApplicationContext().getPackageName(),R.layout.notification_error);
  notification.contentView.setImageViewResource(R.id.status_icon,icon);
  notification.contentView.setTextViewText(R.id.status_text,action);
  notification.contentView.setTextViewText(R.id.status_cancel,text);
  Intent pending=new Intent(self,HomeActivity.class);
  pending.putExtra("com.bigpupdev.synodroid.notifyId",ERROR_ID);
  notification.contentIntent=PendingIntent.getActivity(self,1,pending,0);
  final NotificationManager notificationManager=(NotificationManager)self.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
  notificationManager.notify(INFO_ID,notification);
}