Java Code Examples for android.app.NotificationManager

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 AlarmApp-Android, under directory /src/org/alarmapp/util/.

Source file: NotificationUtil.java

  20 
vote

public static void notifyUser(Context c,int id,String title,String message,Class<?> cls,Bundle bundle,Uri sound,int defaults){
  String ns=Context.NOTIFICATION_SERVICE;
  NotificationManager notificationManager=(NotificationManager)c.getSystemService(ns);
  Notification notification=createNotification(title,sound);
  Intent notificationIntent=new Intent(c,cls);
  if (bundle != null)   notificationIntent.putExtras(bundle);
  PendingIntent contentIntent=PendingIntent.getActivity(c,0,notificationIntent,PendingIntent.FLAG_CANCEL_CURRENT);
  notification.setLatestEventInfo(c,title,message,contentIntent);
  notification.defaults=defaults;
  notificationManager.notify(id,notification);
}
 

Example 2

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/activity/.

Source file: NowPlayingNotificationManager.java

  18 
vote

public void showNotification(String artist,String title,String text,int icon){
  Notification notification=buildNotification(artist + " - " + title,text,icon);
  final String ns=Context.NOTIFICATION_SERVICE;
  NotificationManager notificationManager=(NotificationManager)mContext.getSystemService(ns);
  notificationManager.notify(NOW_PLAYING_ID,notification);
}
 

Example 3

From project androidtracks, under directory /src/org/sfcta/cycletracks/.

Source file: RecordingService.java

  18 
vote

private void clearNotifications(){
  NotificationManager mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  mNotificationManager.cancelAll();
  if (timer != null) {
    timer.cancel();
    timer.purge();
  }
}
 

Example 4

From project android_packages_apps_Exchange, under directory /src/com/android/exchange/.

Source file: CalendarSyncEnabler.java

  18 
vote

/** 
 * Show the "Exchange calendar added" notification.
 * @param emailAddresses space delimited list of email addresses of Exchange accounts.  It'llbe shown on the notification.
 */
void showNotificationForTest(String emailAddresses){
  PendingIntent launchCalendarPendingIntent=PendingIntent.getActivity(mContext,0,createLaunchCalendarIntent(),0);
  String tickerText=mContext.getString(R.string.notification_exchange_calendar_added);
  Notification n=new Notification(R.drawable.stat_notify_calendar,tickerText,System.currentTimeMillis());
  n.setLatestEventInfo(mContext,tickerText,emailAddresses,launchCalendarPendingIntent);
  n.flags=Notification.FLAG_AUTO_CANCEL;
  NotificationManager nm=(NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
  nm.notify(NOTIFICATION_ID_EXCHANGE_CALENDAR_ADDED,n);
}
 

Example 5

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: FakePhoneActivity.java

  18 
vote

public void onClick(View v){
  if (mRadioControl == null) {
    Log.e("Phone","SimulatedRadioControl not available, abort!");
    NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    Toast.makeText(FakePhoneActivity.this,"null mRadioControl!",Toast.LENGTH_SHORT).show();
    return;
  }
  mRadioControl.triggerRing(mPhoneNumber.getText().toString());
}
 

Example 6

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/util/.

Source file: Util.java

  18 
vote

public static void showOutdatedNotification(Context context){
  if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(Preferences.OUTDATED_NOTIFICATION,true)) {
    NotificationManager nm=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification=new Notification(R.drawable.stat_su,context.getString(R.string.notif_outdated_ticker),System.currentTimeMillis());
    PendingIntent contentIntent=PendingIntent.getActivity(context,0,new Intent(context,UpdaterActivity.class),0);
    notification.setLatestEventInfo(context,context.getString(R.string.notif_outdated_title),context.getString(R.string.notif_outdated_text),contentIntent);
    notification.flags|=Notification.FLAG_AUTO_CANCEL;
    nm.notify(UpdaterService.NOTIFICATION_ID,notification);
  }
}
 

Example 7

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/ui/tutorials/.

Source file: TutorialsProvider.java

  18 
vote

public synchronized static void showNotificationIcon(Context context,IntentToLaunch notificationData){
  final NotificationManager mngr=((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE));
  Notification notification=new Notification(notificationData.NotificationIcon,context.getText(notificationData.NotificationText),System.currentTimeMillis());
  PendingIntent contentIntent=PendingIntent.getActivity(context,0,notificationData.IntentToStart,0);
  notification.setLatestEventInfo(context,context.getText(notificationData.NotificationTitle),context.getText(notificationData.NotificationText),contentIntent);
  notification.defaults=0;
  notification.flags=Notification.FLAG_AUTO_CANCEL;
  mngr.notify(notificationData.NotificationID,notification);
}
 

Example 8

From project apps-for-android, under directory /Photostream/src/com/google/android/photostream/.

Source file: PhotostreamActivity.java

  18 
vote

private void clearNotification(){
  final int notification=getIntent().getIntExtra(EXTRA_NOTIFICATION,-1);
  if (notification != -1) {
    NotificationManager manager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    manager.cancel(notification);
  }
}
 

Example 9

From project Birthday-widget, under directory /Birthday/src/main/java/cz/krtinec/birthday/.

Source file: NotificationSender.java

  18 
vote

protected static void fireBirthdayAlert(Context ctx,Event c,Long when){
  String label=formatLabel(ctx,c);
  Notification n=new Notification(R.drawable.icon,label,when);
  n.flags=n.flags | Notification.FLAG_AUTO_CANCEL;
  n.defaults=Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS;
  Intent i=new Intent(ctx,Birthday.class);
  PendingIntent pendingIntent=PendingIntent.getActivity(ctx,NOTIFY_CODE,i,PendingIntent.FLAG_CANCEL_CURRENT);
  n.setLatestEventInfo(ctx,label,formatMessage(ctx,c),pendingIntent);
  NotificationManager manager=(NotificationManager)ctx.getSystemService(Context.NOTIFICATION_SERVICE);
  manager.notify("Birthday",(int)c.getContactId(),n);
}
 

Example 10

From project cw-advandroid, under directory /Broadcast/Ordered/src/com/commonsware/android/ordered/.

Source file: NoticeReceiver.java

  18 
vote

@Override public void onReceive(Context context,Intent intent){
  NotificationManager mgr=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  Notification note=new Notification(R.drawable.stat_notify_chat,"Yoo-hoo! Wake up!",System.currentTimeMillis());
  PendingIntent i=PendingIntent.getActivity(context,0,new Intent(context,OrderedActivity.class),0);
  note.setLatestEventInfo(context,"You Care About This!","...but not enough to keep the activity running",i);
  mgr.notify(NOTIFY_ME_ID,note);
}
 

Example 11

From project cw-omnibus, under directory /EmPubLite/T18-Notify/src/com/commonsware/empublite/.

Source file: InstallReceiver.java

  18 
vote

@Override public void onReceive(Context ctxt,Intent i){
  NotificationCompat.Builder builder=new NotificationCompat.Builder(ctxt);
  Intent toLaunch=new Intent(ctxt,EmPubLiteActivity.class);
  PendingIntent pi=PendingIntent.getActivity(ctxt,0,toLaunch,0);
  builder.setAutoCancel(true).setContentIntent(pi).setContentTitle(ctxt.getString(R.string.update_complete)).setContentText(ctxt.getString(R.string.update_desc)).setSmallIcon(android.R.drawable.stat_sys_download_done).setTicker(ctxt.getString(R.string.update_complete)).setWhen(System.currentTimeMillis());
  NotificationManager mgr=((NotificationManager)ctxt.getSystemService(Context.NOTIFICATION_SERVICE));
  mgr.notify(NOTIFY_ID,builder.build());
}
 

Example 12

From project cwac-updater, under directory /src/com/commonsware/cwac/updater/.

Source file: NotificationConfirmationStrategy.java

  18 
vote

@Override public boolean confirm(Context ctxt,PendingIntent contentIntent){
  NotificationManager mgr=(NotificationManager)ctxt.getSystemService(Context.NOTIFICATION_SERVICE);
  notification.contentIntent=contentIntent;
  mgr.notify(NOTIFICATION_ID,notification);
  return (false);
}
 

Example 13

From project DeskSMS, under directory /DeskSMS/src/com/koushikdutta/desktopsms/.

Source file: ServiceHelper.java

  18 
vote

static void createAuthenticationNotification(Context context){
  NotificationManager n=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  Notification notification=new Notification(R.drawable.icon,context.getString(R.string.authentification_notification),System.currentTimeMillis());
  notification.contentView=new RemoteViews(context.getPackageName(),R.layout.notification);
  Intent intent=new Intent(context,MainActivity.class);
  intent.putExtra("relogin",true);
  notification.contentIntent=PendingIntent.getActivity(context,0,intent,Intent.FLAG_ACTIVITY_NEW_TASK);
  n.cancel(444);
  n.notify(444,notification);
}
 

Example 14

From project DigitbooksExamples, under directory /DigitbooksExamples/src/fr/digitbooks/android/examples/chapitre02/.

Source file: WelcomeReceiver.java

  18 
vote

@Override public void onReceive(Context context,Intent intent){
  NotificationManager mNotificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  Notification notification=new Notification(android.R.drawable.stat_notify_error,"Welcome",System.currentTimeMillis());
  PendingIntent contentIntent=PendingIntent.getActivity(context,0,new Intent(context,ClockActivity.class),0);
  notification.setLatestEventInfo(context,"ClockActivity","Les exemples Digit books sont install?",contentIntent);
  mNotificationManager.notify(NOTIFICATION_ID,notification);
}
 

Example 15

From project ElectricSleep, under directory /src/com/androsz/electricsleepbeta/alarmclock/.

Source file: AlarmAlertFullScreen.java

  18 
vote

private void dismiss(final boolean killed){
  Log.i(killed ? "Alarm killed" : "Alarm dismissed by user");
  if (!killed) {
    final NotificationManager nm=getNotificationManager();
    nm.cancel(mAlarm.id);
    stopService(new Intent(Alarms.ALARM_ALERT_ACTION));
    sendBroadcast(new Intent(Alarms.ALARM_DISMISSED_BY_USER_ACTION));
  }
  finish();
}
 

Example 16

From project FBReaderJ, under directory /src/org/geometerplus/android/fbreader/network/.

Source file: BookDownloaderService.java

  18 
vote

@Override public void onDestroy(){
  final NotificationManager notificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  for (  int notificationId : myOngoingNotifications) {
    notificationManager.cancel(notificationId);
  }
  myOngoingNotifications.clear();
  super.onDestroy();
}
 

Example 17

From project FileExplorer, under directory /src/net/micode/fileexplorer/.

Source file: Util.java

  18 
vote

public static void showNotification(Context context,Intent intent,String title,String body,int drawableId){
  NotificationManager manager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  Notification notification=new Notification(drawableId,body,System.currentTimeMillis());
  notification.flags=Notification.FLAG_AUTO_CANCEL;
  notification.defaults=Notification.DEFAULT_SOUND;
  if (intent == null) {
    intent=new Intent(context,FileViewActivity.class);
  }
  PendingIntent contentIntent=PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_ONE_SHOT);
  notification.setLatestEventInfo(context,title,body,contentIntent);
  manager.notify(drawableId,notification);
}
 

Example 18

From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.

Source file: FileUploadService.java

  18 
vote

private void showSuccessMsg(Context ctx){
  NotificationManager mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  int icon=R.drawable.arrow_up;
  CharSequence tickerText="Upload succeeded!";
  long when=System.currentTimeMillis();
  Notification notification=new Notification(icon,tickerText,when);
  notification.flags|=Notification.FLAG_AUTO_CANCEL;
  Context context=getApplicationContext();
  PendingIntent nullIntent=PendingIntent.getActivity(context,0,new Intent(),0);
  notification.setLatestEventInfo(context,tickerText,"Click to dismiss",nullIntent);
  mNotificationManager.notify(UPLOAD_SUCCESS_ID,notification);
}
 

Example 19

From project gast-lib, under directory /app/src/root/gast/playground/location/.

Source file: ProximityAlertBroadcastReceiver.java

  18 
vote

private void displayNotification(Context context,String message){
  NotificationManager notificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  PendingIntent pi=PendingIntent.getActivity(context,0,new Intent(),0);
  Notification notification=new Notification(R.drawable.icon,message,System.currentTimeMillis());
  notification.setLatestEventInfo(context,"GAST","Proximity Alert",pi);
  notificationManager.notify(NOTIFICATION_ID,notification);
}
 

Example 20

From project GCM-Demo, under directory /gcm/samples/gcm-demo-client/src/com/google/android/gcm/demo/app/.

Source file: GCMIntentService.java

  18 
vote

/** 
 * Issues a notification to inform the user that server has sent a message.
 */
private static void generateNotification(Context context,String message){
  int icon=R.drawable.ic_stat_gcm;
  long when=System.currentTimeMillis();
  NotificationManager notificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  Notification notification=new Notification(icon,message,when);
  String title=context.getString(R.string.app_name);
  Intent notificationIntent=new Intent(context,DemoActivity.class);
  notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
  PendingIntent intent=PendingIntent.getActivity(context,0,notificationIntent,0);
  notification.setLatestEventInfo(context,title,message,intent);
  notification.flags|=Notification.FLAG_AUTO_CANCEL;
  notificationManager.notify(0,notification);
}
 

Example 21

From project Gibberbot, under directory /src/info/guardianproject/otr/app/im/plugin/xmpp/.

Source file: ServerTrustManager.java

  18 
vote

private void showToolbarNotification(String title,String notifyMsg,int notifyId,int icon,int flags,Intent nIntent) throws Exception {
  NotificationManager mNotificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  CharSequence tickerText=notifyMsg;
  long when=System.currentTimeMillis();
  Notification notification=new Notification(icon,tickerText,when);
  if (flags > 0) {
    notification.flags|=flags;
  }
  CharSequence contentTitle=context.getString(R.string.app_name) + ": " + title;
  CharSequence contentText=notifyMsg;
  PendingIntent contentIntent=PendingIntent.getActivity(context,0,nIntent,0);
  notification.setLatestEventInfo(context,contentTitle,contentText,contentIntent);
  mNotificationManager.notify(notifyId,notification);
}
 

Example 22

From project gobandroid, under directory /src/org/ligi/gobandroid_hd/ui/.

Source file: GobandroidNotifications.java

  18 
vote

public static void addGoLinkNotification(Context context,String golink){
  NotificationManager notificationManager=(NotificationManager)context.getSystemService(Activity.NOTIFICATION_SERVICE);
  Notification notification=new Notification(R.drawable.ic_launcher,"The Go Game you reviewed",System.currentTimeMillis());
  Intent notificationIntent=new Intent(context,GoLinkLoadActivity.class);
  notificationIntent.setData(Uri.parse(golink));
  PendingIntent pendingIntent=PendingIntent.getActivity(context,0,notificationIntent,0);
  notification.defaults=Notification.FLAG_ONLY_ALERT_ONCE + Notification.FLAG_AUTO_CANCEL;
  notification.setLatestEventInfo(context,"The Go Game you reviewed",golink,pendingIntent);
  notificationManager.notify(GOLINK_NOTIFICATION_ID,notification);
}
 

Example 23

From project hiofenigma-android, under directory /opentimer/src/edu/killerud/kitchentimer/.

Source file: CountdownService.java

  18 
vote

private void showAlarmFinishedNotification(){
  NotificationManager nm=(NotificationManager)getSystemService(android.app.Activity.NOTIFICATION_SERVICE);
  Notification notification=new Notification(R.drawable.icon_notification,getString(R.string.notification),System.currentTimeMillis());
  Intent resumeActivity=new Intent(this,OpenTimerActivity.class);
  resumeActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
  notification.setLatestEventInfo(this,getString(R.string.notification_title),getString(R.string.notification),PendingIntent.getActivity(this,0,resumeActivity,0));
  notification.defaults|=Notification.DEFAULT_LIGHTS;
  notification.defaults|=Notification.FLAG_INSISTENT;
  notification.defaults|=Notification.FLAG_AUTO_CANCEL;
  nm.notify(1,notification);
}
 

Example 24

From project keepassdroid, under directory /src/com/keepassdroid/services/.

Source file: TimeoutService.java

  18 
vote

private void timeout(Context context){
  Log.d(TAG,"Timeout");
  App.setShutdown();
  NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  nm.cancelAll();
  stopSelf();
}
 

Example 25

From project lastfm-android, under directory /app/src/fm/last/android/.

Source file: LastFm.java

  18 
vote

@Override public void onPostExecute(Boolean result){
  if (result) {
    NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    Notification notification=new Notification(R.drawable.as_statusbar,getString(R.string.newversion_ticker_text),System.currentTimeMillis());
    PendingIntent contentIntent=PendingIntent.getActivity(LastFm.this,0,new Intent(Intent.ACTION_VIEW,Uri.parse(mUpdateURL)),0);
    notification.setLatestEventInfo(LastFm.this,getString(R.string.newversion_info_title),getString(R.string.newversion_info_text),contentIntent);
    nm.notify(12345,notification);
  }
}
 

Example 26

From project LitHub, under directory /LitHub-Android/src/us/lithub/.

Source file: Util.java

  18 
vote

/** 
 * Display a notification containing the given string.
 */
public static void generateNotification(Context context,String message){
  int icon=R.drawable.status_icon;
  long when=System.currentTimeMillis();
  Notification notification=new Notification(icon,message,when);
  notification.setLatestEventInfo(context,"C2DM Example",message,PendingIntent.getActivity(context,0,null,PendingIntent.FLAG_CANCEL_CURRENT));
  notification.flags|=Notification.FLAG_AUTO_CANCEL;
  SharedPreferences settings=Util.getSharedPreferences(context);
  int notificatonID=settings.getInt("notificationID",0);
  NotificationManager nm=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  nm.notify(notificatonID,notification);
  SharedPreferences.Editor editor=settings.edit();
  editor.putInt("notificationID",++notificatonID % 32);
  editor.commit();
}
 

Example 27

From project maven-android-plugin-samples, under directory /apidemos-android-10/application/src/main/java/com/example/android/apis/app/.

Source file: IncomingMessage.java

  18 
vote

/** 
 * The notification is the icon and associated expanded entry in the status bar.
 */
protected void showNotification(){
  NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  CharSequence from="Joe";
  CharSequence message="kthx. meet u for dinner. cul8r";
  PendingIntent contentIntent=PendingIntent.getActivity(this,0,new Intent(this,IncomingMessageView.class),0);
  String tickerText=getString(R.string.imcoming_message_ticker_text,message);
  Notification notif=new Notification(R.drawable.stat_sample,tickerText,System.currentTimeMillis());
  notif.setLatestEventInfo(this,from,message,contentIntent);
  notif.vibrate=new long[]{100,250,100,500};
  nm.notify(R.string.imcoming_message_ticker_text,notif);
}
 

Example 28

From project MIT-Mobile-for-Android, under directory /src/edu/mit/mitmobile2/alerts/.

Source file: C2DMReceiver.java

  18 
vote

protected void notifyUser(Context context,String statusBarText,String alarmTitle,String alarmText,int iconResID,PendingIntent pendingIntent){
  NotificationManager notificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  long curTime=System.currentTimeMillis();
  Notification notify=new Notification(iconResID,statusBarText,curTime);
  notify.setLatestEventInfo(context,alarmTitle,alarmText,pendingIntent);
  notify.flags=Notification.FLAG_AUTO_CANCEL;
  notify.defaults=Notification.DEFAULT_ALL;
  notificationManager.notify((int)curTime,notify);
}
 

Example 29

From project mobilis, under directory /MXA/src/de/tudresden/inf/rn/mobilis/mxa/.

Source file: XMPPRemoteService.java

  18 
vote

@Override public void onCreate(){
  super.onCreate();
  NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  nm.cancel(XMPPSERVICE_STATUS);
  instance=this;
}
 

Example 30

From project ohmagePhone, under directory /src/org/ohmage/.

Source file: NotificationHelper.java

  18 
vote

public static void showNotification(Context context,String title,String message,Intent intent){
  NotificationManager noteManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  Notification note=new Notification();
  PendingIntent pendingIntent=PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
  note.icon=R.drawable.ic_stat_warning;
  note.tickerText=title;
  note.defaults|=Notification.DEFAULT_ALL;
  note.when=System.currentTimeMillis();
  note.flags=Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE;
  note.setLatestEventInfo(context,title,message,pendingIntent);
  noteManager.notify(4,note);
}
 

Example 31

From project OneMoreDream, under directory /src/com/dixheure/.

Source file: AlarmAlertFullScreen.java

  18 
vote

private void dismiss(boolean killed){
  if (!killed) {
    Intent intent=new Intent(AlarmKlaxon.TRACK_WAKEUP);
    intent.putExtra(AlarmKlaxon.TRACK_EXTRA,track);
    sendBroadcast(intent);
    NotificationManager nm=getNotificationManager();
    nm.cancel(mAlarm.id);
    stopService(new Intent(Alarms.ALARM_ALERT_ACTION));
  }
  finish();
}
 

Example 32

From project openpomo, under directory /src/it/unibz/pomodroid/.

Source file: Pomodoro.java

  18 
vote

/** 
 * Notifies the user in various ways
 * @param message The message we want to display to the user
 */
private void notifyUser(String message,boolean vibrate){
  NotificationManager nm=(NotificationManager)context.getSystemService(NOTIFICATION_SERVICE);
  Notification notification=new Notification(R.drawable.pomo_red,"Pomodroid",System.currentTimeMillis());
  Intent intent=new Intent(context,Pomodoro.class);
  TextView atvActivitySummary=(TextView)findViewById(R.id.atvActivitySummary);
  String activitySummary=(String)atvActivitySummary.getText();
  notification.setLatestEventInfo(Pomodoro.this,activitySummary,message,PendingIntent.getActivity(getBaseContext(),0,intent,PendingIntent.FLAG_CANCEL_CURRENT));
  notification.flags|=Notification.FLAG_AUTO_CANCEL;
  notification.ledARGB=0xff00ff00;
  notification.defaults|=Notification.DEFAULT_LIGHTS;
  if (vibrate && getUser().isVibration())   notification.defaults|=Notification.DEFAULT_VIBRATE;
  nm.notify(NOTIFICATION_ID,notification);
  Toast.makeText(context,message,Toast.LENGTH_LONG).show();
}
 

Example 33

From project packages_apps_Phone_1, under directory /src/com/android/phone/.

Source file: FakePhoneActivity.java

  18 
vote

public void onClick(View v){
  if (mRadioControl == null) {
    Log.e("Phone","SimulatedRadioControl not available, abort!");
    NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    Toast.makeText(FakePhoneActivity.this,"null mRadioControl!",Toast.LENGTH_SHORT).show();
    return;
  }
  mRadioControl.triggerRing(mPhoneNumber.getText().toString());
}
 

Example 34

From project packages_apps_ROMControl, under directory /src/com/aokp/romcontrol/fragments/.

Source file: LEDControl.java

  18 
vote

@Override public void onReceive(Context context,Intent intent){
  final String action=intent.getAction();
  final NotificationManager nm=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  if (action.equals(Intent.ACTION_SCREEN_OFF)) {
    Notification.Builder nb=new Notification.Builder(context);
    nb.setAutoCancel(true);
    nb.setLights(userColor,onBlink,offBlink);
    Notification test=nb.getNotification();
    nm.notify(1,test);
  }
 else   if (action.equals(Intent.ACTION_SCREEN_ON)) {
    nm.cancel(1);
  }
}
 

Example 35

From project platform_packages_apps_alarmclock, under directory /src/com/android/alarmclock/.

Source file: AlarmAlertFullScreen.java

  18 
vote

private void dismiss(boolean killed){
  if (!killed) {
    NotificationManager nm=getNotificationManager();
    nm.cancel(mAlarm.id);
    stopService(new Intent(Alarms.ALARM_ALERT_ACTION));
  }
  finish();
}
 

Example 36

From project platform_packages_apps_calendar, under directory /src/com/android/calendar/alerts/.

Source file: AlertActivity.java

  18 
vote

@Override public void onClick(View v){
  if (v == mDismissAllButton) {
    NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancelAll();
    dismissFiredAlarms();
    finish();
  }
}
 

Example 37

From project platform_packages_apps_contacts, under directory /src/com/android/contacts/calllog/.

Source file: DefaultVoicemailNotifier.java

  18 
vote

/** 
 * Returns the singleton instance of the  {@link DefaultVoicemailNotifier}. 
 */
public static synchronized DefaultVoicemailNotifier getInstance(Context context){
  if (sInstance == null) {
    NotificationManager notificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    ContentResolver contentResolver=context.getContentResolver();
    sInstance=new DefaultVoicemailNotifier(context,notificationManager,createNewCallsQuery(contentResolver),createNameLookupQuery(contentResolver),createPhoneNumberHelper(context));
  }
  return sInstance;
}
 

Example 38

From project platform_packages_apps_CytownPhone, under directory /src/com/android/phone/.

Source file: FakePhoneActivity.java

  18 
vote

public void onClick(View v){
  if (mRadioControl == null) {
    Log.e("Phone","SimulatedRadioControl not available, abort!");
    NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    Toast.makeText(FakePhoneActivity.this,"null mRadioControl!",Toast.LENGTH_SHORT).show();
    return;
  }
  mRadioControl.triggerRing(mPhoneNumber.getText().toString());
}
 

Example 39

From project platform_packages_apps_phone, under directory /src/com/android/phone/.

Source file: FakePhoneActivity.java

  18 
vote

public void onClick(View v){
  if (mRadioControl == null) {
    Log.e("Phone","SimulatedRadioControl not available, abort!");
    NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    Toast.makeText(FakePhoneActivity.this,"null mRadioControl!",Toast.LENGTH_SHORT).show();
    return;
  }
  mRadioControl.triggerRing(mPhoneNumber.getText().toString());
}
 

Example 40

From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.

Source file: C2DMReceiver.java

  17 
vote

private void handleMessage(final Context context,final Intent intent){
  String message=intent.getStringExtra("alert");
  String title="Push received!";
  if (ApplicationStatus.isVisible()) {
    final Dialog dialog=new Dialog(ApplicationStatus.getCurrentActivity(),R.style.MobeelizerDialogTheme);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.info_dialog);
    TextView titleView=(TextView)dialog.findViewById(R.id.dialogTitle);
    titleView.setText(title);
    TextView textView=(TextView)dialog.findViewById(R.id.dialogText);
    textView.setText(message);
    Button closeButton=(Button)dialog.findViewById(R.id.dialogButton);
    closeButton.setOnClickListener(new View.OnClickListener(){
      public void onClick(      final View paramView){
        dialog.dismiss();
      }
    }
);
    dialog.show();
  }
 else {
    Notification notification=new Notification(R.drawable.ic_launcher,message,System.currentTimeMillis());
    notification.setLatestEventInfo(context,title,message,null);
    notification.flags|=Notification.FLAG_AUTO_CANCEL;
    NotificationManager notificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(i++,notification);
  }
}
 

Example 41

From project android-tether, under directory /src/og/android/tether/.

Source file: C2DMReceiver.java

  17 
vote

public static void generateNotification(Context context,String msg,String title,Intent intent){
  int icon=R.drawable.icon_og_bev;
  long when=System.currentTimeMillis();
  Notification notification=new Notification(icon,title,when);
  notification.setLatestEventInfo(context,title,msg,PendingIntent.getActivity(context,0,intent,0));
  notification.flags|=Notification.FLAG_AUTO_CANCEL;
  notification.defaults=Notification.DEFAULT_ALL;
  Log.d(TAG,"notification: " + notification.toString());
  SharedPreferences settings=prefs(context);
  int notificatonID=settings.getInt("notificationID",0);
  NotificationManager nm=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  nm.notify(notificatonID,notification);
  playNotificationSound(context);
  SharedPreferences.Editor editor=settings.edit();
  editor.putInt("notificationID",++notificatonID % 32);
  editor.commit();
}
 

Example 42

From project android_7, under directory /src/org/immopoly/android/notification/.

Source file: UserNotification.java

  17 
vote

public static void showNotification(Context context,String type,String message,String title){
  final int typeOfNotification=Integer.parseInt(type);
  int icon;
switch (typeOfNotification) {
case 1:
    icon=R.drawable.house;
  break;
default :
icon=R.drawable.ic_map_button;
break;
}
CharSequence tickerText=message;
long when=System.currentTimeMillis();
Context appContext=context.getApplicationContext();
CharSequence contentTitle=title;
CharSequence contentText=message;
Intent notificationIntent=new Intent(context,ImmopolyActivity.class);
notificationIntent.putExtra(ImmopolyActivity.C2DM_START,ImmopolyActivity.START_HISTORY);
PendingIntent contentIntent=PendingIntent.getActivity(context,0,notificationIntent,0);
Notification notification=new Notification(icon,tickerText,when);
notification.setLatestEventInfo(appContext,contentTitle,contentText,contentIntent);
notification.flags=Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;
String ns=Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager=(NotificationManager)appContext.getSystemService(ns);
mNotificationManager.notify(1,notification);
}
 

Example 43

From project android_packages_apps_CellBroadcastReceiver, under directory /src/com/android/cellbroadcastreceiver/.

Source file: CellBroadcastAlertService.java

  17 
vote

/** 
 * Display a full-screen alert message for emergency alerts.
 * @param message the alert to display
 */
private void openEmergencyAlertNotification(CellBroadcastMessage message){
  acquireTimedWakelock(WAKE_LOCK_TIMEOUT);
  Intent closeDialogs=new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  sendBroadcast(closeDialogs);
  Intent audioIntent=new Intent(this,CellBroadcastAlertAudio.class);
  audioIntent.setAction(CellBroadcastAlertAudio.ACTION_START_ALERT_AUDIO);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
  String duration=prefs.getString(CellBroadcastSettings.KEY_ALERT_SOUND_DURATION,CellBroadcastSettings.ALERT_SOUND_DEFAULT_DURATION);
  audioIntent.putExtra(CellBroadcastAlertAudio.ALERT_AUDIO_DURATION_EXTRA,Integer.parseInt(duration));
  int channelTitleId=CellBroadcastResources.getDialogTitleResource(message);
  CharSequence channelName=getText(channelTitleId);
  String messageBody=message.getMessageBody();
  if (prefs.getBoolean(CellBroadcastSettings.KEY_ENABLE_ALERT_SPEECH,true)) {
    audioIntent.putExtra(CellBroadcastAlertAudio.ALERT_AUDIO_MESSAGE_BODY,messageBody);
    String language=message.getLanguageCode();
    if (message.isEtwsMessage() && !"ja".equals(language)) {
      Log.w(TAG,"bad language code for ETWS - using Japanese TTS");
      language="ja";
    }
 else     if (message.isCmasMessage() && !"en".equals(language)) {
      Log.w(TAG,"bad language code for CMAS - using English TTS");
      language="en";
    }
    audioIntent.putExtra(CellBroadcastAlertAudio.ALERT_AUDIO_MESSAGE_LANGUAGE,language);
  }
  startService(audioIntent);
  int notificationId=(int)message.getDeliveryTime();
  Class c=CellBroadcastAlertDialog.class;
  KeyguardManager km=(KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
  if (km.inKeyguardRestrictedInputMode()) {
    c=CellBroadcastAlertFullScreen.class;
  }
  Intent notify=createDisplayMessageIntent(this,c,message,notificationId);
  PendingIntent pi=PendingIntent.getActivity(this,notificationId,notify,0);
  Notification.Builder builder=new Notification.Builder(this).setSmallIcon(R.drawable.ic_notify_alert).setTicker(getText(CellBroadcastResources.getDialogTitleResource(message))).setWhen(System.currentTimeMillis()).setContentIntent(pi).setFullScreenIntent(pi,true).setContentTitle(channelName).setContentText(messageBody).setDefaults(Notification.DEFAULT_LIGHTS);
  NotificationManager notificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  notificationManager.notify(notificationId,builder.getNotification());
}
 

Example 44

From project androvoip, under directory /src/org/androvoip/iax2/.

Source file: IAX2Service.java

  17 
vote

/** 
 * @see com.mexuar.corraleta.protocol.ProtocolEventListener#registered(com.mexuar.corraleta.protocol.Friend,boolean)
 */
public void registered(Friend f,boolean s){
  final Intent intent=new Intent(this,AndroVoIP.class);
  final PendingIntent pendingIntent=PendingIntent.getActivity(this,0,intent,0);
  final NotificationManager notificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  final CharSequence mText=s ? "Registered" : "Unregistered";
  final Notification notification=new Notification(R.drawable.icon,getString(R.string.app_name) + " " + mText,System.currentTimeMillis());
  notification.setLatestEventInfo(this,getString(R.string.app_name) + " " + mText,f != null ? f.getStatus() : "",pendingIntent);
  notification.flags|=Notification.FLAG_AUTO_CANCEL;
  notificationManager.notify(0,notification);
  this.registered=s;
  if (s) {
    this.friend=f;
  }
 else   if (this.friend != null) {
    this.friend.stop();
    this.friend=null;
  }
}
 

Example 45

From project andstatus, under directory /src/org/andstatus/app/.

Source file: MyService.java

  17 
vote

/** 
 * Notify user of the commands Queue size
 * @return total size of Queues
 */
private int notifyOfQueue(boolean clearNotification){
  int count=mRetryQueue.size() + mCommands.size();
  NotificationManager nM=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  if (count == 0 || clearNotification) {
    nM.cancel(CommandEnum.NOTIFY_QUEUE.ordinal());
  }
 else   if (mNotificationsEnabled) {
    if (mRetryQueue.size() > 0) {
      MyLog.d(TAG,mRetryQueue.size() + " commands in Retry Queue.");
    }
    if (mCommands.size() > 0) {
      MyLog.d(TAG,mCommands.size() + " commands in Main Queue.");
    }
    Notification notification=new Notification(R.drawable.notification_icon,(String)getText(R.string.notification_title),System.currentTimeMillis());
    int messageTitle;
    String aMessage="";
    aMessage=I18n.formatQuantityMessage(getApplicationContext(),R.string.notification_queue_format,count,R.array.notification_queue_patterns,R.array.notification_queue_formats);
    messageTitle=R.string.notification_title_queue;
    notification.tickerText=aMessage;
    PendingIntent pi=PendingIntent.getBroadcast(this,0,new CommandData(CommandEnum.EMPTY,"").toIntent(),0);
    notification.setLatestEventInfo(this,getText(messageTitle),aMessage,pi);
    nM.notify(CommandEnum.NOTIFY_QUEUE.ordinal(),notification);
  }
  return count;
}
 

Example 46

From project andtweet, under directory /src/com/xorcode/andtweet/.

Source file: AndTweetService.java

  17 
vote

/** 
 * Notify user of the commands Queue size
 * @return total size of Queues
 */
private int notifyOfQueue(boolean clearNotification){
  int count=mRetryQueue.size() + mCommands.size();
  NotificationManager nM=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  if (count == 0 || clearNotification) {
    nM.cancel(CommandEnum.NOTIFY_QUEUE.ordinal());
  }
 else   if (mNotificationsEnabled) {
    if (mRetryQueue.size() > 0) {
      d(TAG,mRetryQueue.size() + " commands in Retry Queue.");
    }
    if (mCommands.size() > 0) {
      d(TAG,mCommands.size() + " commands in Main Queue.");
    }
    Notification notification=new Notification(R.drawable.notification_icon,(String)getText(R.string.notification_title),System.currentTimeMillis());
    int messageTitle;
    String aMessage="";
    aMessage=I18n.formatQuantityMessage(getApplicationContext(),R.string.notification_queue_format,count,R.array.notification_queue_patterns,R.array.notification_queue_formats);
    messageTitle=R.string.notification_title_queue;
    notification.tickerText=aMessage;
    PendingIntent pi=PendingIntent.getBroadcast(this,0,new CommandData(CommandEnum.EMPTY).toIntent(),0);
    notification.setLatestEventInfo(this,getText(messageTitle),aMessage,pi);
    nM.notify(CommandEnum.NOTIFY_QUEUE.ordinal(),notification);
  }
  return count;
}
 

Example 47

From project Anki-Android, under directory /src/com/ichi2/anki/services/.

Source file: DownloadManagerService.java

  17 
vote

/** 
 * Show a notification informing the user when a deck is ready to be used
 */
private void showNotification(String deckTitle){
  NotificationManager mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  Resources res=getResources();
  Notification notification=new Notification(R.drawable.anki,res.getString(R.string.download_finished),System.currentTimeMillis());
  Intent loadDeckIntent=new Intent(Intent.ACTION_VIEW,Uri.parse(mDestination + "/" + deckTitle+ ".anki"),DownloadManagerService.this,StudyOptions.class);
  PendingIntent contentIntent=PendingIntent.getActivity(this,0,loadDeckIntent,0);
  notification.setLatestEventInfo(this,deckTitle,res.getString(R.string.deck_downloaded),contentIntent);
  notification.flags|=Notification.FLAG_AUTO_CANCEL;
  notification.defaults|=Notification.DEFAULT_VIBRATE;
  notification.ledARGB=0xff0000ff;
  notification.ledOnMS=500;
  notification.ledOffMS=1000;
  notification.flags|=Notification.FLAG_SHOW_LIGHTS;
  Log.i(AnkiDroidApp.TAG,"Sending notification...");
  mNotificationManager.notify(getNextNotificationId(),notification);
}
 

Example 48

From project creamed_glacier_app_settings, under directory /src/com/android/settings/bluetooth/.

Source file: BluetoothPairingRequest.java

  17 
vote

@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
    BluetoothDevice device=intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    int type=intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,BluetoothDevice.ERROR);
    Intent pairingIntent=new Intent();
    pairingIntent.setClass(context,BluetoothPairingDialog.class);
    pairingIntent.putExtra(BluetoothDevice.EXTRA_DEVICE,device);
    pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,type);
    if (type == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION || type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY || type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) {
      int pairingKey=intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY,BluetoothDevice.ERROR);
      pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY,pairingKey);
    }
    pairingIntent.setAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
    pairingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PowerManager powerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    String deviceAddress=device != null ? device.getAddress() : null;
    if (powerManager.isScreenOn() && LocalBluetoothPreferences.shouldShowDialogInForeground(context,deviceAddress)) {
      context.startActivity(pairingIntent);
    }
 else {
      Resources res=context.getResources();
      Notification.Builder builder=new Notification.Builder(context).setSmallIcon(android.R.drawable.stat_sys_data_bluetooth).setTicker(res.getString(R.string.bluetooth_notif_ticker));
      PendingIntent pending=PendingIntent.getActivity(context,0,pairingIntent,PendingIntent.FLAG_ONE_SHOT);
      String name=intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
      if (TextUtils.isEmpty(name)) {
        name=device != null ? device.getAliasName() : context.getString(android.R.string.unknownName);
      }
      builder.setContentTitle(res.getString(R.string.bluetooth_notif_title)).setContentText(res.getString(R.string.bluetooth_notif_message,name)).setContentIntent(pending).setAutoCancel(true).setDefaults(Notification.DEFAULT_SOUND);
      NotificationManager manager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
      manager.notify(NOTIFICATION_ID,builder.getNotification());
    }
  }
 else   if (action.equals(BluetoothDevice.ACTION_PAIRING_CANCEL)) {
    NotificationManager manager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    manager.cancel(NOTIFICATION_ID);
  }
}
 

Example 49

From project DeliciousDroid, under directory /src/com/deliciousdroid/action/.

Source file: AddBookmarkTask.java

  17 
vote

private void throwError(){
  NotificationManager nm=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  Random r=new Random();
  int notification=r.nextInt();
  Notification n=new Notification(R.drawable.ic_main,"DeliciousDroid Error",System.currentTimeMillis());
  Intent ni=new Intent(context,AddBookmark.class);
  ni.setAction(Intent.ACTION_SEND);
  ni.setData(Uri.parse("content://com.deliciousdroid.bookmarks/" + Integer.toString(notification)));
  ni.putExtra(Intent.EXTRA_TEXT,bookmark.getUrl());
  ni.putExtra(Constants.EXTRA_DESCRIPTION,bookmark.getDescription());
  ni.putExtra(Constants.EXTRA_NOTES,bookmark.getNotes());
  ni.putExtra(Constants.EXTRA_TAGS,bookmark.getTagString());
  ni.putExtra(Constants.EXTRA_PRIVATE,bookmark.getPrivate());
  ni.putExtra(Constants.EXTRA_ERROR,true);
  if (update) {
    ni.putExtra(Intent.EXTRA_TEXT + ".old",oldBookmark.getUrl());
    ni.putExtra(Constants.EXTRA_DESCRIPTION + ".old",oldBookmark.getDescription());
    ni.putExtra(Constants.EXTRA_NOTES + ".old",oldBookmark.getNotes());
    ni.putExtra(Constants.EXTRA_TAGS + ".old",oldBookmark.getTagString());
    ni.putExtra(Constants.EXTRA_PRIVATE + ".old",oldBookmark.getPrivate());
    ni.putExtra(Constants.EXTRA_TIME + ".old",oldBookmark.getTime());
  }
  ni.putExtra(Constants.EXTRA_UPDATE,update);
  ni.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  n.flags|=Notification.FLAG_AUTO_CANCEL;
  n.flags|=Notification.FLAG_NO_CLEAR;
  PendingIntent ci=PendingIntent.getActivity(context,0,ni,PendingIntent.FLAG_UPDATE_CURRENT);
  n.setLatestEventInfo(context,"DeliciousDroid Error","Error Saving Bookmark",ci);
  nm.notify(notification,n);
}
 

Example 50

From project eclipse-ui-tips, under directory /EclipseUITips/src/name/raev/kaloyan/android/eclipseuitips/.

Source file: AlarmReceiver.java

  17 
vote

@Override public void onReceive(Context context,Intent intent){
  String ns=Context.NOTIFICATION_SERVICE;
  NotificationManager mNotificationManager=(NotificationManager)context.getSystemService(ns);
  Notification notification=new Notification(R.drawable.ic_stat_notify_eclipse,context.getString(R.string.notify_ticker_text),0);
  notification.flags=Notification.FLAG_AUTO_CANCEL;
  Guideline guideline=Guideline.random();
  Intent notificationIntent=new Intent(context,GuidelinesPagerActivity.class);
  notificationIntent.putExtra(Guideline.EXTRA_INDEX,guideline.ordinal());
  notificationIntent.putExtra(Guideline.EXTRA_HIGHLIGHTED,true);
  PendingIntent contentIntent=PendingIntent.getActivity(context,0,notificationIntent,PendingIntent.FLAG_CANCEL_CURRENT);
  CharSequence contentTitle=context.getString(guideline.subcategory().title());
  CharSequence contentText=context.getString(guideline.text());
  notification.setLatestEventInfo(context,contentTitle,contentText,contentIntent);
  mNotificationManager.notify(1,notification);
}
 

Example 51

From project empub, under directory /src/com/commonsware/empub/.

Source file: DownloadCompleteReceiver.java

  17 
vote

@TargetApi(11) @Override public void onReceive(final Context ctxt,Intent unused){
  File update=new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),DownloadCheckTask.UPDATE_FILENAME);
  if (update.exists()) {
    Intent i;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      i=new Intent(Intent.ACTION_INSTALL_PACKAGE);
      i.putExtra(Intent.EXTRA_ALLOW_REPLACE,true);
    }
 else {
      i=new Intent(Intent.ACTION_VIEW);
    }
    i.setDataAndType(Uri.fromFile(update),"application/vnd.android.package-archive");
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    NotificationCompat.Builder b=new NotificationCompat.Builder(ctxt);
    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setWhen(System.currentTimeMillis());
    b.setContentTitle(ctxt.getString(R.string.empub_download_complete)).setContentText(ctxt.getString(R.string.empub_download_install)).setSmallIcon(android.R.drawable.stat_sys_download_done).setTicker(ctxt.getString(R.string.empub_download_complete));
    b.setContentIntent(PendingIntent.getActivity(ctxt,0,i,0));
    NotificationManager mgr=(NotificationManager)ctxt.getSystemService(Context.NOTIFICATION_SERVICE);
    mgr.notify(NOTIFY_ID,b.getNotification());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      final PendingResult pr=goAsync();
      new Thread(){
        public void run(){
          makeMeGoByeBye(ctxt);
          pr.finish();
        }
      }
.start();
    }
 else {
      makeMeGoByeBye(ctxt);
    }
  }
}
 

Example 52

From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/actions/.

Source file: NameTrack.java

  17 
vote

private void startDelayNotification(){
  int resId=R.string.dialog_routename_title;
  int icon=R.drawable.ic_maps_indicator_current_position;
  CharSequence tickerText=getResources().getString(resId);
  long when=System.currentTimeMillis();
  Notification nameNotification=new Notification(icon,tickerText,when);
  nameNotification.flags|=Notification.FLAG_AUTO_CANCEL;
  CharSequence contentTitle=getResources().getString(R.string.app_name);
  CharSequence contentText=getResources().getString(resId);
  Intent notificationIntent=new Intent(this,NameTrack.class);
  notificationIntent.setData(ContentUris.withAppendedId(Tracks.CONTENT_URI,mTrackId));
  PendingIntent contentIntent=PendingIntent.getActivity(this,0,notificationIntent,Intent.FLAG_ACTIVITY_NEW_TASK);
  nameNotification.setLatestEventInfo(this,contentTitle,contentText,contentIntent);
  NotificationManager noticationManager=(NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
  noticationManager.notify(R.layout.namedialog,nameNotification);
}
 

Example 53

From project iosched_3, under directory /android/src/com/google/android/apps/iosched/calendar/.

Source file: SessionAlarmService.java

  17 
vote

private void scheduleAlarm(final long sessionStart,final long sessionEnd,final long alarmOffset){
  NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  nm.cancel(NOTIFICATION_ID);
  final long currentTime=System.currentTimeMillis();
  if (currentTime > sessionStart) {
    return;
  }
  long alarmTime;
  if (alarmOffset == UNDEFINED_ALARM_OFFSET) {
    alarmTime=sessionStart - TEN_MINUTES_MILLIS;
  }
 else {
    alarmTime=currentTime + alarmOffset;
  }
  final Intent alarmIntent=new Intent(ACTION_NOTIFY_SESSION,null,this,SessionAlarmService.class);
  alarmIntent.setData(new Uri.Builder().authority(ScheduleContract.CONTENT_AUTHORITY).path(String.valueOf(sessionStart)).build());
  alarmIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START,sessionStart);
  alarmIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END,sessionEnd);
  alarmIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET,alarmOffset);
  final AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
  am.set(AlarmManager.RTC_WAKEUP,alarmTime,PendingIntent.getService(this,0,alarmIntent,PendingIntent.FLAG_CANCEL_CURRENT));
}
 

Example 54

From project k-9, under directory /src/com/fsck/k9/controller/.

Source file: MessagingController.java

  17 
vote

/** 
 * Display an ongoing notification while a message is being sent.
 * @param account The account the message is sent from. Never  {@code null}.
 */
private void notifyWhileSending(Account account){
  if (!account.isShowOngoing()) {
    return;
  }
  NotificationManager notifMgr=(NotificationManager)mApplication.getSystemService(Context.NOTIFICATION_SERVICE);
  NotificationBuilder builder=NotificationBuilder.createInstance(mApplication);
  builder.setSmallIcon(R.drawable.ic_menu_refresh);
  builder.setWhen(System.currentTimeMillis());
  builder.setOngoing(true);
  builder.setTicker(mApplication.getString(R.string.notification_bg_send_ticker,account.getDescription()));
  builder.setContentTitle(mApplication.getString(R.string.notification_bg_send_title));
  builder.setContentText(account.getDescription());
  Intent intent=MessageList.actionHandleFolderIntent(mApplication,account,account.getInboxFolderName());
  PendingIntent pi=PendingIntent.getActivity(mApplication,0,intent,0);
  builder.setContentIntent(pi);
  if (K9.NOTIFICATION_LED_WHILE_SYNCING) {
    configureNotification(builder,null,null,account.getNotificationSetting().getLedColor(),K9.NOTIFICATION_LED_BLINK_FAST,true);
  }
  notifMgr.notify(K9.FETCHING_EMAIL_NOTIFICATION - account.getAccountNumber(),builder.getNotification());
}
 

Example 55

From project LDAP-Sync, under directory /src/de/danielweisser/android/ldapsync/client/.

Source file: LDAPUtilities.java

  17 
vote

/** 
 * Obtains a list of all contacts from the LDAP Server.
 * @param ldapServer The LDAP server data
 * @param baseDN The baseDN that will be used for the search
 * @param searchFilter The search filter
 * @param mappingBundle A bundle of all LDAP attributes that are queried
 * @param mLastUpdated Date of the last update
 * @param context The caller Activity's context
 * @return List of all LDAP contacts
 */
public static List<Contact> fetchContacts(final LDAPServerInstance ldapServer,final String baseDN,final String searchFilter,final Bundle mappingBundle,final Date mLastUpdated,final Context context){
  final ArrayList<Contact> friendList=new ArrayList<Contact>();
  LDAPConnection connection=null;
  try {
    connection=ldapServer.getConnection();
    SearchResult searchResult=connection.search(baseDN,SearchScope.SUB,searchFilter,getUsedAttributes(mappingBundle));
    Log.i(TAG,searchResult.getEntryCount() + " entries returned.");
    for (    SearchResultEntry e : searchResult.getSearchEntries()) {
      Contact u=Contact.valueOf(e,mappingBundle);
      if (u != null) {
        friendList.add(u);
      }
    }
  }
 catch (  LDAPException e) {
    Log.v(TAG,"LDAPException on fetching contacts",e);
    NotificationManager mNotificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    int icon=R.drawable.icon;
    CharSequence tickerText="Error on LDAP Sync";
    Notification notification=new Notification(icon,tickerText,System.currentTimeMillis());
    Intent notificationIntent=new Intent(context,SyncService.class);
    PendingIntent contentIntent=PendingIntent.getService(context,0,notificationIntent,PendingIntent.FLAG_CANCEL_CURRENT);
    notification.setLatestEventInfo(context,tickerText,e.getMessage().replace("\\n"," "),contentIntent);
    notification.flags=Notification.FLAG_AUTO_CANCEL;
    mNotificationManager.notify(0,notification);
    return null;
  }
 finally {
    if (connection != null) {
      connection.close();
    }
  }
  return friendList;
}
 

Example 56

From project Locast-Android, under directory /src/edu/mit/mobile/android/locast/net/.

Source file: NetworkClient.java

  17 
vote

public void uploadContentWithNotification(Context context,Uri cast,String serverPath,Uri localFile,String contentType,UploadType uploadType) throws NetworkProtocolException, IOException {
  String castTitle=Cast.getTitle(context,cast);
  if (castTitle == null) {
    castTitle="untitled (cast #" + cast.getLastPathSegment() + ")";
  }
  final ProgressNotification notification=new ProgressNotification(context,context.getString(R.string.sync_uploading_cast,castTitle),ProgressNotification.TYPE_UPLOAD,PendingIntent.getActivity(context,0,new Intent(Intent.ACTION_VIEW,cast).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),0),true);
  notification.successful=false;
  notification.doneTitle=context.getString(R.string.sync_upload_fail);
  notification.doneText=context.getString(R.string.sync_upload_fail_message,castTitle);
  notification.doneIntent=PendingIntent.getActivity(context,0,new Intent(Intent.ACTION_VIEW,cast).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),0);
  final NotificationManager nm=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  final NotificationProgressListener tpl=new NotificationProgressListener(nm,notification,0,(int)ContentUris.parseId(cast));
  try {
    final AssetFileDescriptor afd=context.getContentResolver().openAssetFileDescriptor(localFile,"r");
    final long max=afd.getLength();
    tpl.setSize(max);
switch (uploadType) {
case RAW_PUT:
      uploadContent(context,tpl,serverPath,localFile,contentType);
    break;
case FORM_POST:
  uploadContentUsingForm(context,tpl,serverPath,localFile,contentType);
break;
}
notification.doneTitle=context.getString(R.string.sync_upload_success);
notification.doneText=context.getString(R.string.sync_upload_success_message,castTitle);
notification.successful=true;
}
 catch (final NetworkProtocolException e) {
notification.setUnsuccessful(e.getLocalizedMessage());
throw e;
}
catch (final IOException e) {
notification.setUnsuccessful(e.getLocalizedMessage());
throw e;
}
 finally {
tpl.done();
}
}
 

Example 57

From project myPlan, under directory /src/com/conzebit/myplan/android/receiver/.

Source file: AfterCallReceiver.java

  17 
vote

@Override public void onReceive(Context context,Intent intent){
  if (!Settings.isTrapAfterCall(context)) {
    return;
  }
  NotificationManager notificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  Bundle extras=intent.getExtras();
  if (extras != null) {
    String state=extras.getString(TelephonyManager.EXTRA_STATE);
    if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
      incomingCall=true;
    }
 else     if (TelephonyManager.EXTRA_STATE_IDLE.equals(state)) {
      if (!incomingCall) {
        try {
synchronized (context) {
            context.wait(5000);
          }
        }
 catch (        Exception e) {
        }
        AndroidMsisdnTypeStore androidMsisdnTypeStore=new AndroidMsisdnTypeStore(context);
        MsisdnTypeService.getInstance(androidMsisdnTypeStore);
        Call lastCall=LogStoreService.getInstance().getLastCall(context);
        if (lastCall != null && lastCall.getDuration() > 0 && lastCall.getType() == Call.CALL_TYPE_SENT) {
          notifyUser(context,notificationManager);
        }
      }
      incomingCall=false;
    }
  }
}
 

Example 58

From project Ohmage_Phone, under directory /src/org/ohmage/.

Source file: NotificationHelper.java

  17 
vote

public static void showAuthNotification(Context context){
  NotificationManager noteManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  Notification note=new Notification();
  Intent intentToLaunch=new Intent(context,LoginActivity.class);
  PendingIntent pendingIntent=PendingIntent.getActivity(context,0,intentToLaunch,0);
  String title="Authentication error!";
  String body="Tap here to re-enter credentials.";
  note.icon=android.R.drawable.stat_notify_error;
  note.tickerText="Authentication error!";
  note.defaults|=Notification.DEFAULT_ALL;
  note.when=System.currentTimeMillis();
  note.flags=Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE;
  note.setLatestEventInfo(context,title,body,pendingIntent);
  noteManager.notify(1,note);
}
 

Example 59

From project OpenAndroidWeather, under directory /OpenAndroidWeather/src/no/firestorm/weathernotificatonservice/.

Source file: WeatherNotificationService.java

  17 
vote

/** 
 * Make notification and post it to the NotificationManager
 * @param tickerIcon Icon shown in notification bar
 * @param contentIcon Icon shown in notification
 * @param tickerText Text shown in notification bar
 * @param contentTitle Title shown in notification
 * @param contentText Description shown in notification
 * @param contentTime Time shown in notification
 * @param when2
 */
private void makeNotification(int tickerIcon,int contentIcon,CharSequence tickerText,CharSequence contentTitle,CharSequence contentText,CharSequence contentTime,long when2,Float temperature){
  final long when=System.currentTimeMillis();
  Notification notification=null;
  final Intent notificationIntent=new Intent(WeatherNotificationService.this,WeatherNotificationService.class);
  final PendingIntent contentIntent=PendingIntent.getService(WeatherNotificationService.this,0,notificationIntent,0);
  if (Build.VERSION.SDK_INT >= 11) {
    NotificationBuilder builder=new NotificationBuilder(this);
    builder.setAutoCancel(false);
    builder.setContentTitle(contentTitle);
    builder.setContentText(contentText);
    builder.setTicker(tickerText);
    builder.setWhen(when2);
    builder.setSmallIcon(tickerIcon);
    builder.setOngoing(true);
    builder.setContentIntent(contentIntent);
    if (temperature != null)     builder.makeContentView(contentTitle,contentText,when2,temperature,tickerIcon);
    notification=builder.getNotification();
  }
 else {
    notification=new Notification(tickerIcon,tickerText,when);
    notification.flags=Notification.FLAG_ONGOING_EVENT;
    final RemoteViews contentView=new RemoteViews(getPackageName(),R.layout.weathernotification);
    contentView.setImageViewResource(R.id.icon,contentIcon);
    contentView.setTextViewText(R.id.title,contentTitle);
    contentView.setTextViewText(R.id.title,contentTitle);
    contentView.setTextViewText(R.id.text,contentText);
    contentView.setTextViewText(R.id.time,contentTime);
    notification.contentView=contentView;
  }
  notification.contentIntent=contentIntent;
  final NotificationManager mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  mNotificationManager.notify(1,notification);
}
 

Example 60

From project packages_apps_Calendar, under directory /src/com/android/calendar/alerts/.

Source file: AlertActivity.java

  17 
vote

@Override public void onClick(View v){
  if (v == mSnoozeAllButton) {
    long alarmTime=System.currentTimeMillis() + SNOOZE_DELAY;
    NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(NOTIFICATION_ID);
    if (mCursor != null) {
      long scheduleAlarmTime=0;
      mCursor.moveToPosition(-1);
      while (mCursor.moveToNext()) {
        long eventId=mCursor.getLong(INDEX_EVENT_ID);
        long begin=mCursor.getLong(INDEX_BEGIN);
        long end=mCursor.getLong(INDEX_END);
        ContentValues values=makeContentValues(eventId,begin,end,alarmTime,0);
        if (mCursor.isLast()) {
          scheduleAlarmTime=alarmTime;
        }
        mQueryHandler.startInsert(0,scheduleAlarmTime,CalendarAlerts.CONTENT_URI,values,Utils.UNDO_DELAY);
      }
    }
 else {
      Log.d(TAG,"Cursor object is null. Ignore the Snooze request.");
    }
    dismissFiredAlarms();
    finish();
  }
 else   if (v == mDismissAllButton) {
    NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(NOTIFICATION_ID);
    dismissFiredAlarms();
    finish();
  }
}
 

Example 61

From project packages_apps_God_Mode, under directory /src/com/t3hh4xx0r/addons/nightlies/.

Source file: OMFGBNightlyActivity.java

  17 
vote

@Override public void onReceive(Context context,Intent intent){
  Log.e(TAG,"I am receiver");
  if (intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
    Log.e(TAG,"Reciving " + DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    String ns=Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager=(NotificationManager)getSystemService(ns);
    int icon=R.drawable.icon;
    CharSequence tickerText="T3hh4xx0r";
    long when=System.currentTimeMillis();
    CharSequence contentTitle="OMFGB Nightlies";
    CharSequence contentText="Download completed";
    Intent notificationIntent=new Intent(context,OMFGBNightlyActivity.class);
    PendingIntent contentIntent=PendingIntent.getActivity(context,0,notificationIntent,0);
    Notification notification=new Notification(icon,tickerText,when);
    notification.setLatestEventInfo(context,contentTitle,contentText,contentIntent);
    final int HELLO_ID=1;
    mNotificationManager.notify(HELLO_ID,notification);
  }
  if (intent.getAction().equals(DownloadManager.ACTION_NOTIFICATION_CLICKED)) {
    Log.e(TAG,"Reciving " + DownloadManager.ACTION_NOTIFICATION_CLICKED);
    Intent notificationIntent=new Intent(context,OMFGBNightlyActivity.class);
    startActivity(notificationIntent);
  }
}
 

Example 62

From project platform_packages_apps_browser, under directory /src/com/android/browser/.

Source file: WebStorageSizeManager.java

  17 
vote

private void scheduleOutOfSpaceNotification(){
  if (LOGV_ENABLED) {
    Log.v(LOGTAG,"scheduleOutOfSpaceNotification called.");
  }
  if ((mLastOutOfSpaceNotificationTime == -1) || (System.currentTimeMillis() - mLastOutOfSpaceNotificationTime > NOTIFICATION_INTERVAL)) {
    int icon=android.R.drawable.stat_sys_warning;
    CharSequence title=mContext.getString(R.string.webstorage_outofspace_notification_title);
    CharSequence text=mContext.getString(R.string.webstorage_outofspace_notification_text);
    long when=System.currentTimeMillis();
    Intent intent=new Intent(mContext,BrowserPreferencesPage.class);
    intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,WebsiteSettingsFragment.class.getName());
    PendingIntent contentIntent=PendingIntent.getActivity(mContext,0,intent,0);
    Notification notification=new Notification(icon,title,when);
    notification.setLatestEventInfo(mContext,title,text,contentIntent);
    notification.flags|=Notification.FLAG_AUTO_CANCEL;
    String ns=Context.NOTIFICATION_SERVICE;
    NotificationManager mgr=(NotificationManager)mContext.getSystemService(ns);
    if (mgr != null) {
      mLastOutOfSpaceNotificationTime=System.currentTimeMillis();
      mgr.notify(OUT_OF_SPACE_ID,notification);
    }
  }
}
 

Example 63

From project platform_packages_apps_mms, under directory /src/com/android/mms/transaction/.

Source file: SimFullReceiver.java

  17 
vote

@Override public void onReceive(Context context,Intent intent){
  if (Settings.Secure.getInt(context.getContentResolver(),Settings.Secure.DEVICE_PROVISIONED,0) == 1 && Telephony.Sms.Intents.SIM_FULL_ACTION.equals(intent.getAction())) {
    NotificationManager nm=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    Intent viewSimIntent=new Intent(context,ManageSimMessages.class);
    viewSimIntent.setAction(Intent.ACTION_VIEW);
    viewSimIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent=PendingIntent.getActivity(context,0,viewSimIntent,0);
    Notification notification=new Notification();
    notification.icon=R.drawable.stat_sys_no_sim;
    notification.tickerText=context.getString(R.string.sim_full_title);
    notification.defaults=Notification.DEFAULT_ALL;
    notification.setLatestEventInfo(context,context.getString(R.string.sim_full_title),context.getString(R.string.sim_full_body),pendingIntent);
    nm.notify(ManageSimMessages.SIM_FULL_NOTIFICATION_ID,notification);
  }
}
 

Example 64

From project agit, under directory /agit/src/main/java/com/madgag/agit/operation/lifecycle/.

Source file: RepoNotifications.java

  15 
vote

@Inject public RepoNotifications(Context context,@Named("gitdir") File gitdir,PendingIntent manageGitRepo){
  this.context=context;
  this.manageGitRepo=manageGitRepo;
  this.ongoingOpNotificationId=gitdir.hashCode();
  this.completionNotificationId=ongoingOpNotificationId + 1;
  this.promptNotificationId=completionNotificationId + 1;
  notificationManager=(NotificationManager)context.getSystemService(NOTIFICATION_SERVICE);
}
 

Example 65

From project aksunai, under directory /src/org/androidnerds/app/aksunai/service/.

Source file: ChatManager.java

  15 
vote

@Override public void onCreate(){
  Log.i(AppConstants.CHAT_TAG,"Creating the chat service.");
  mPrefs=getSharedPreferences("aksunai-prefs",MODE_PRIVATE);
  mPrefs.registerOnSharedPreferenceChangeListener(this);
  mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  setForeground(true);
  running=true;
}
 

Example 66

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/synchronisation/tracks/service/.

Source file: SynchronizationService.java

  15 
vote

@Override public void onCreate(){
  String ns=Context.NOTIFICATION_SERVICE;
  mNotificationManager=(NotificationManager)getSystemService(ns);
  contentView=new RemoteViews(getPackageName(),R.layout.synchronize_notification_layout);
  contentView.setProgressBar(R.id.progress_horizontal,100,50,true);
  contentView.setImageViewResource(R.id.image,R.drawable.shuffle_icon);
  mHandler=new Handler();
  mCheckTimer=new CheckTimer();
  mPerformSynch=new PerformSynch();
  mHandler.post(mCheckTimer);
}
 

Example 67

From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/compat/.

Source file: ServiceForegroundCompat.java

  15 
vote

public ServiceForegroundCompat(Service service){
  this.service=service;
  mNM=(NotificationManager)service.getSystemService(Context.NOTIFICATION_SERVICE);
  Class<?> clazz=service.getClass();
  try {
    mStartForeground=clazz.getMethod("startForeground",mStartForegroundSig);
    mStopForeground=clazz.getMethod("stopForeground",mStopForegroundSig);
  }
 catch (  NoSuchMethodException e) {
    mStartForeground=mStopForeground=null;
  }
  try {
    mSetForeground=clazz.getMethod("setForeground",mSetForegroundSig);
  }
 catch (  NoSuchMethodException e) {
    mSetForeground=null;
  }
  if (mStartForeground == null && mSetForeground == null) {
    throw new IllegalStateException("Neither startForeground() or setForeground() present!");
  }
}
 

Example 68

From project android-voip-service, under directory /src/main/java/org/linphone/.

Source file: LinphoneService.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  instance=this;
  LinphonePreferenceManager.getInstance(this);
  PreferenceManager.setDefaultValues(this,R.xml.linphone_preferences,true);
  notificationTitle=getString(R.string.app_name);
  Hacks.dumpDeviceInformation();
  dumpInstalledLinphoneInformation();
  mNotificationMgr=(NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
  mNotif=new Notification(R.drawable.status_level,"",System.currentTimeMillis());
  mNotif.iconLevel=IC_LEVEL_ORANGE;
  mNotif.flags|=Notification.FLAG_ONGOING_EVENT;
  Intent notifIntent=new Intent(this,LinphoneActivity.class);
  mNotifContentIntent=PendingIntent.getActivity(this,0,notifIntent,0);
  mNotif.setLatestEventInfo(this,notificationTitle,"",mNotifContentIntent);
  mNotificationMgr.notify(NOTIF_ID,mNotif);
  LinphoneManager.createAndStart(this,this);
}
 

Example 69

From project Android_1, under directory /org.eclipse.ecf.android.server/src/org/eclipse/ecf/android/server/.

Source file: ServerContainer.java

  15 
vote

/** 
 * Standard initialization of this activity. Set up the UI, then wait for the user to poke it before doing anything.
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  ecfIntent=new Intent(ECFTCP_INTENT);
  ecfIntent.setData(Uri.parse(ECFTCP_URI));
  ecfIntent.setFlags(0);
  nMgr=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  setContentView(R.layout.remote_service_binding);
  mStartServiceButton=(Button)findViewById(R.id.start);
  mStartServiceButton.setEnabled(false);
  mStartServiceButton.setOnClickListener(mStartService);
  mStartContainerButton=(Button)findViewById(R.id.connect);
  mStartContainerButton.setOnClickListener(mStartContainer);
  mBindButton=(Button)findViewById(R.id.bind_service);
  mBindButton.setOnClickListener(mBindListener);
  mCallbackText=(TextView)findViewById(R.id.callback);
  mCallbackText.setText("Not attached.");
}
 

Example 70

From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/led/.

Source file: PackageSettingsActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.led_package);
  setResult(RESULT_CANCELED);
  mCategoryPref=(ListPreference)findPreference("category");
  mCategoryPref.setOnPreferenceChangeListener(this);
  populateCategories();
  mForceModePref=(ListPreference)findPreference("force_mode");
  mForceModePref.setOnPreferenceChangeListener(this);
  mColorPref=(ListPreference)findPreference("color");
  mColorPref.setOnPreferenceChangeListener(this);
  mBlinkPref=(ListPreference)findPreference("blink");
  mBlinkPref.setOnPreferenceChangeListener(this);
  mCustomPref=findPreference("custom_color");
  mTestPref=findPreference("test_color");
  mResetPref=findPreference("reset");
  mSavePref=findPreference("save");
  String[] colorList=getResources().getStringArray(com.android.internal.R.array.notification_led_random_color_set);
  mColorList=new int[colorList.length];
  for (int i=0; i < colorList.length; i++) {
    mColorList[i]=Color.parseColor(colorList[i]);
  }
  mNM=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  populateColors();
  updateUiForCapabilities();
  loadInitialData();
}
 

Example 71

From project android_packages_apps_Nfc, under directory /src/com/android/nfc/handover/.

Source file: HandoverManager.java

  15 
vote

public HandoverManager(Context context){
  mContext=context;
  mBluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
  if (mBluetoothAdapter != null) {
    mBluetoothAdapter.getProfileProxy(mContext,this,BluetoothProfile.HEADSET);
    mBluetoothAdapter.getProfileProxy(mContext,this,BluetoothProfile.A2DP);
  }
  mNotificationManager=(NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
  mTransfers=new HashMap<Pair<String,Boolean>,HandoverTransfer>();
  mHandoverPowerManager=new HandoverPowerManager(context);
  IntentFilter filter=new IntentFilter(ACTION_BT_OPP_TRANSFER_DONE);
  filter.addAction(ACTION_BT_OPP_TRANSFER_PROGRESS);
  filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
  filter.addAction(ACTION_CANCEL_HANDOVER_TRANSFER);
  mContext.registerReceiver(mReceiver,filter,HANDOVER_STATUS_PERMISSION,null);
}
 

Example 72

From project Backyard-Brains-Android-App, under directory /src/com/backyardbrains/audio/.

Source file: AudioService.java

  15 
vote

/** 
 * Instantiate  {@link MicListener} thread, tell it to start, and put up thenotification via  {@link AudioService#showNotification()}
 */
public void turnOnMicThread(){
  micThread=null;
  micThread=new MicListener();
  micThread.start(AudioService.this);
  mNM=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  showNotification(true);
  Log.d(TAG,"Mic thread started");
}
 

Example 73

From project BART, under directory /src/pro/dbro/bart/.

Source file: UsherService.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  c=this;
  mNM=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  LocalBroadcastManager.getInstance(this).registerReceiver(serviceDataMessageReceiver,new IntentFilter("service_status_change"));
}
 

Example 74

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: BookCatalogueApp.java

  15 
vote

/** 
 * Most real initialization should go here, since before this point, the App is still 'Under Construction'.
 */
@Override public void onCreate(){
  ACRA.init(this);
  mNotifier=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  BookCatalogueApp.context=this.getApplicationContext();
  if (mQueueManager == null)   mQueueManager=new BcQueueManager(this.getApplicationContext());
  super.onCreate();
}
 

Example 75

From project bookmarktodesktop-android-application, under directory /src/be/vbsteven/bmtodesk/.

Source file: BackgroundSharingService.java

  15 
vote

@Override public void onStart(Intent intent,int startId){
  super.onStart(intent,startId);
  nManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  if (intent.hasExtra(Global.EXTRA_TITLE) && intent.hasExtra(Global.EXTRA_URL)) {
    title=intent.getStringExtra(Global.EXTRA_TITLE);
    url=intent.getStringExtra(Global.EXTRA_URL);
    Log.d(Global.TAG,"started BackgroundSharingService with values " + title + " "+ url);
    sendToServer(title,url);
  }
 else {
    stopSelf();
    return;
  }
}
 

Example 76

From project com.juick.android, under directory /src/com/juick/android/.

Source file: CheckUpdatesReceiver.java

  15 
vote

@Override public void onReceive(Context context,Intent intent){
  final String jsonStr=Utils.getJSON(context,"http://api.juick.com/notifications");
  if (jsonStr != null && jsonStr.length() > 4) {
    try {
      JSONObject json=new JSONObject(jsonStr);
      int messages=json.getInt("messages");
      String str="New messages: " + messages;
      Intent i=new Intent(context,MainActivity.class);
      PendingIntent contentIntent=PendingIntent.getActivity(context,0,i,PendingIntent.FLAG_UPDATE_CURRENT);
      Notification notification=new Notification(R.drawable.ic_notification,str,System.currentTimeMillis());
      notification.setLatestEventInfo(context.getApplicationContext(),str,str,contentIntent);
      notification.flags|=Notification.FLAG_AUTO_CANCEL;
      notification.defaults|=Notification.DEFAULT_LIGHTS;
      ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(1,notification);
    }
 catch (    JSONException e) {
      Log.e("CheckUpdatesReceiver",e.toString());
    }
  }
}
 

Example 77

From project COSsettings, under directory /src/com/cyanogenmod/cmparts/activities/led/.

Source file: PackageSettingsActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.led_package);
  setResult(RESULT_CANCELED);
  mCategoryPref=(ListPreference)findPreference("category");
  mCategoryPref.setOnPreferenceChangeListener(this);
  populateCategories();
  mForceModePref=(ListPreference)findPreference("force_mode");
  mForceModePref.setOnPreferenceChangeListener(this);
  mColorPref=(ListPreference)findPreference("color");
  mColorPref.setOnPreferenceChangeListener(this);
  mBlinkPref=(ListPreference)findPreference("blink");
  mBlinkPref.setOnPreferenceChangeListener(this);
  mCustomPref=findPreference("custom_color");
  mTestPref=findPreference("test_color");
  mResetPref=findPreference("reset");
  mSavePref=findPreference("save");
  String[] colorList=getResources().getStringArray(com.android.internal.R.array.notification_led_random_color_set);
  mColorList=new int[colorList.length];
  for (int i=0; i < colorList.length; i++) {
    mColorList[i]=Color.parseColor(colorList[i]);
  }
  mNM=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  populateColors();
  updateUiForCapabilities();
  loadInitialData();
}
 

Example 78

From project Cura, under directory /src/com/cura/ServerStats/.

Source file: ServerStatsActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.setContentView(R.layout.serverstats);
  this.setTitle(R.string.ServerStatsTitle);
  Bundle extras=getIntent().getExtras();
  if (extras != null) {
    userTemp=extras.getParcelable("user");
  }
  initView();
  doBindService();
  getStats();
  killProcessesButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View arg0){
      AlertDialog.Builder builder=new AlertDialog.Builder(ServerStatsActivity.this);
      builder.setTitle("Pick a process");
      builder.setItems(processIDs,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int item){
          sendAndReceive("kill `pidof " + processIDs[item] + "`");
          getStats();
        }
      }
);
      builder.show();
    }
  }
);
  mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
}
 

Example 79

From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/.

Source file: StreamingService.java

  15 
vote

@Override public void onDestroy(){
  if (needStoppedNotification) {
    ((NotificationManager)getSystemService(NOTIFICATION_SERVICE)).cancel(STREAMINGSERVICE_PAUSED);
    Notification status=new NotificationCompat.Builder(this).setContentTitle(getString(R.string.streamStopped)).setSmallIcon(R.drawable.icon).setContentIntent(PendingIntent.getActivity(this,0,new Intent("com.namelessdev.mpdroid.PLAYBACK_VIEWER").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK),0)).getNotification();
    ((NotificationManager)getSystemService(NOTIFICATION_SERVICE)).notify(STREAMINGSERVICE_STOPPED,status);
  }
  isServiceRunning=false;
  setMusicState(PLAYSTATE_STOPPED);
  unregisterMediaButtonEvent();
  unregisterRemoteControlClient();
  audioManager.abandonAudioFocus(this);
  if (mediaPlayer != null) {
    mediaPlayer.stop();
    mediaPlayer.release();
    mediaPlayer=null;
  }
  MPDApplication app=(MPDApplication)getApplication();
  app.unsetActivity(this);
  app.getApplicationState().streamingMode=false;
  super.onDestroy();
}
 

Example 80

From project dungbeetle, under directory /src/edu/stanford/mobisocial/dungbeetle/.

Source file: DungBeetleService.java

  15 
vote

@Override public void onCreate(){
  mHelper=DBHelper.getGlobal(this);
  mNotificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  mMessagingManagerThread=new MessagingManagerThread(this);
  mMessagingManagerThread.start();
  if (ContentCorral.CONTENT_CORRAL_ENABLED) {
    mContentCorral=new ContentCorral(this);
    mContentCorral.start();
  }
}
 

Example 81

From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/service/.

Source file: TwitterService.java

  15 
vote

@Override public void onCreate(){
  Log.v(TAG,"Server Created");
  super.onCreate();
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  mWakeLock.acquire();
  boolean needCheck=TwitterApplication.mPref.getBoolean(Preferences.CHECK_UPDATES_KEY,false);
  boolean widgetIsEnabled=TwitterService.widgetIsEnabled;
  Log.v(TAG,"Check Updates is " + needCheck + "/wg:"+ widgetIsEnabled);
  if (!needCheck && !widgetIsEnabled) {
    Log.d(TAG,"Check update preference is false.");
    stopSelf();
    return;
  }
  if (!getApi().isLoggedIn()) {
    Log.d(TAG,"Not logged in.");
    stopSelf();
    return;
  }
  schedule(TwitterService.this);
  mNotificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  mNewTweets=new ArrayList<Tweet>();
  mNewMentions=new ArrayList<Tweet>();
  mNewDms=new ArrayList<Dm>();
  if (mRetrieveTask != null && mRetrieveTask.getStatus() == GenericTask.Status.RUNNING) {
    return;
  }
 else {
    mRetrieveTask=new RetrieveTask();
    mRetrieveTask.setListener(mRetrieveTaskListener);
    mRetrieveTask.execute((TaskParams[])null);
  }
}
 

Example 82

From project gmarks-android, under directory /src/main/java/org/thomnichols/android/gmarks/.

Source file: RemoteSyncTask.java

  15 
vote

RemoteSyncTask(Context ctx){
  this.ctx=ctx;
  notificationManager=(NotificationManager)ctx.getSystemService(Context.NOTIFICATION_SERVICE);
  notification=new Notification(R.drawable.ic_sync,ctx.getString(R.string.sync_notify_start),System.currentTimeMillis());
  this.syncPrefs=Prefs.get(this.ctx);
  this.legacySyncPrefs=ctx.getSharedPreferences(SHARED_PREFS_NAME,Context.MODE_PRIVATE);
}
 

Example 83

From project HapiPodcastJ, under directory /src/info/xuluan/podcast/service/.

Source file: PlayerService.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  mPlayer=new MyPlayer();
  mPlayer.setHandler(handler);
  mNotificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  TelephonyManager tmgr=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
  tmgr.listen(mPhoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
  log.debug("onCreate()");
}
 

Example 84

From project HarleyDroid, under directory /src/org/harleydroid/.

Source file: HarleyDroidService.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  if (D)   Log.d(TAG,"onCreate()");
  mHD=new HarleyData();
  J1850.resetCounters();
  mNM=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  notification=new Notification(R.drawable.ic_stat_notify_harleydroid,"",System.currentTimeMillis());
  notification.flags=Notification.FLAG_ONGOING_EVENT;
  notificationIntent=PendingIntent.getActivity(this,0,new Intent(this,HarleyDroidDashboard.class),0);
  notify(R.string.notification_connecting);
}
 

Example 85

From project jamendo-android, under directory /src/com/teleca/jamendo/service/.

Source file: DownloadService.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  Log.i(JamendoApplication.TAG,"DownloadService.onCreate");
  mNotificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  mDownloadProvider=JamendoApplication.getInstance().getDownloadManager().getProvider();
}
 

Example 86

From project LoL-Chat, under directory /src/com/rei/lolchat/.

Source file: BeemService.java

  15 
vote

/** 
 * {@inheritDoc}
 */
@Override public void onCreate(){
  super.onCreate();
  registerReceiver(mReceiver,new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
  mSettings=PreferenceManager.getDefaultSharedPreferences(this);
  mSettings.registerOnSharedPreferenceChangeListener(mPreferenceListener);
  if (mSettings.getBoolean(BeemApplication.USE_AUTO_AWAY_KEY,false)) {
    mOnOffReceiverIsRegistered=true;
    registerReceiver(mOnOffReceiver,new IntentFilter(Intent.ACTION_SCREEN_OFF));
    registerReceiver(mOnOffReceiver,new IntentFilter(Intent.ACTION_SCREEN_ON));
  }
  String tmpJid=mSettings.getString(BeemApplication.ACCOUNT_USERNAME_KEY,"").trim() + "@pvp.net";
  mLogin=StringUtils.parseName(tmpJid);
  mPassword="AIR_" + mSettings.getString(BeemApplication.ACCOUNT_PASSWORD_KEY,"");
  mPort=DEFAULT_XMPP_PORT;
  mService=StringUtils.parseServer(tmpJid);
  mHost=mService;
  if (mSettings.getBoolean("settings_key_specific_server",false)) {
    mHost=mSettings.getString("settings_key_xmpp_server","").trim();
    if ("".equals(mHost))     mHost=mService;
    String tmpPort=mSettings.getString("settings_key_xmpp_port","5223");
    if (!"".equals(tmpPort))     mPort=Integer.parseInt(tmpPort);
  }
  if (mSettings.getBoolean(BeemApplication.FULL_JID_LOGIN_KEY,false) || "gmail.com".equals(mService) || "googlemail.com".equals(mService)) {
    mLogin=tmpJid;
  }
  initConnectionConfig();
  configure(ProviderManager.getInstance());
  mNotificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  mConnection=new XmppConnectionAdapter(mConnectionConfiguration,mLogin,mPassword,this);
  Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
  mBind=new XmppFacade(mConnection);
  Log.d(TAG,"Create BeemService");
}
 

Example 87

From project milton, under directory /milton/apps/milton-android-photouploader/src/com/ettrema/android/photouploader/.

Source file: ApplicationNotification.java

  15 
vote

/** 
 * Enable application notification
 * @param application Main application instance
 */
public void enable(Context context){
  if (isEnabled) {
    return;
  }
  try {
    manager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification=new Notification(R.drawable.uploader,null,System.currentTimeMillis());
    notification.flags|=Notification.FLAG_ONGOING_EVENT;
    Intent notificationIntent=new Intent(context,MiltonPhotoUploader.class);
    PendingIntent contentIntent=PendingIntent.getActivity(context,0,notificationIntent,0);
    notification.setLatestEventInfo(context,context.getString(R.string.app_name),context.getString(R.string.app_name) + " is running.",contentIntent);
    manager.notify(APP_NOTIFICAION,notification);
    isEnabled=true;
  }
 catch (  Exception e) {
  }
}
 

Example 88

From project milton2, under directory /apps/milton-android-photouploader/src/com/ettrema/android/photouploader/.

Source file: ApplicationNotification.java

  15 
vote

/** 
 * Enable application notification
 * @param application Main application instance
 */
public void enable(Context context){
  if (isEnabled) {
    return;
  }
  try {
    manager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification=new Notification(R.drawable.uploader,null,System.currentTimeMillis());
    notification.flags|=Notification.FLAG_ONGOING_EVENT;
    Intent notificationIntent=new Intent(context,MiltonPhotoUploader.class);
    PendingIntent contentIntent=PendingIntent.getActivity(context,0,notificationIntent,0);
    notification.setLatestEventInfo(context,context.getString(R.string.app_name),context.getString(R.string.app_name) + " is running.",contentIntent);
    manager.notify(APP_NOTIFICAION,notification);
    isEnabled=true;
  }
 catch (  Exception e) {
  }
}
 

Example 89

From project mp3tunes-android, under directory /src/com/mp3tunes/android/service/.

Source file: Mp3tunesService.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  mNm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  mBufferPercent=0;
  setForeground(true);
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MP3tunes Player");
  WifiManager wm=(WifiManager)getSystemService(Context.WIFI_SERVICE);
  mWifiLock=wm.createWifiLock("MP3tunes Player");
  mTelephonyManager=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
  mTelephonyManager.listen(mPhoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
  mTrackHistory=new Stack<Integer>();
  mLocker=(Locker)MP3tunesApplication.getInstance().map.get("mp3tunes_locker");
  try {
    mDb=new LockerDb(this,null);
  }
 catch (  Exception ex) {
    System.out.println(ex.getMessage());
    ex.printStackTrace();
    mServiceState=STATE.STOPPED;
    notifyChange(DATABASE_ERROR);
    mNm.cancel(NOTIFY_ID);
    if (mWakeLock.isHeld())     mWakeLock.release();
    if (mWifiLock.isHeld())     mWifiLock.release();
  }
}
 

Example 90

From project mWater-Android-App, under directory /android/src/co/mwater/clientapp/dbsync/.

Source file: SyncIntentService.java

  15 
vote

@Override protected void onHandleIntent(Intent intent){
  lastPercent=-1;
  DataSlice slice=intent.getParcelableExtra("dataSlice");
  boolean includeImages=intent.getBooleanExtra("includeImages",false);
  if (notificationManager == null)   notificationManager=(NotificationManager)getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
  try {
    notifyProgress(0);
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException e) {
    }
    synchronizeDatabase(slice);
    SourceCodes.requestNewCodesIfNeeded(getApplicationContext());
    if (includeImages)     uploadImages();
    notifyFinished();
  }
 catch (  SyncServerException e) {
    Log.w(TAG,e.getLocalizedMessage());
    notifyError(e.getLocalizedMessage());
  }
catch (  RESTClientException e) {
    Log.w(TAG,e.getLocalizedMessage());
    notifyError(e.getLocalizedMessage());
  }
catch (  IOException e) {
    Log.w(TAG,e.getLocalizedMessage());
    notifyError(e.getLocalizedMessage());
  }
}
 

Example 91

From project No-Pain-No-Game, under directory /src/edu/ucla/cs/nopainnogame/pedometer/.

Source file: StepService.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  mNM=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  showNotification();
  mSettings=PreferenceManager.getDefaultSharedPreferences(this);
  mPedometerSettings=new PedometerSettings(mSettings);
  mState=getSharedPreferences("state",0);
  acquireWakeLock();
  mStepDetector=new StepDetector();
  mSensorManager=(SensorManager)getSystemService(SENSOR_SERVICE);
  registerDetector();
  IntentFilter filter=new IntentFilter(Intent.ACTION_SCREEN_OFF);
  registerReceiver(mReceiver,filter);
  mStepDisplayer=new StepDisplayer(mPedometerSettings,mTts);
  mStepDisplayer.setSteps(mSteps=mState.getInt("steps",0));
  mStepDisplayer.addListener(mStepListener);
  mStepDetector.addStepListener(mStepDisplayer);
  mPaceNotifier=new PaceNotifier(mPedometerSettings,mTts);
  mPaceNotifier.setPace(mPace=mState.getInt("pace",0));
  mPaceNotifier.addListener(mPaceListener);
  mStepDetector.addStepListener(mPaceNotifier);
  mDistanceNotifier=new DistanceNotifier(mDistanceListener,mPedometerSettings,mTts);
  mDistanceNotifier.setDistance(mDistance=mState.getFloat("distance",0));
  mStepDetector.addStepListener(mDistanceNotifier);
  mSpeedNotifier=new SpeedNotifier(mSpeedListener,mPedometerSettings,mTts);
  mSpeedNotifier.setSpeed(mSpeed=mState.getFloat("speed",0));
  mPaceNotifier.addListener(mSpeedNotifier);
  mCaloriesNotifier=new CaloriesNotifier(mCaloriesListener,mPedometerSettings,mTts);
  mCaloriesNotifier.setCalories(mCalories=mState.getFloat("calories",0));
  mStepDetector.addStepListener(mCaloriesNotifier);
  mSpeakingTimer=new SpeakingTimer(mPedometerSettings);
  mSpeakingTimer.addListener(mStepDisplayer);
  mSpeakingTimer.addListener(mPaceNotifier);
  mSpeakingTimer.addListener(mDistanceNotifier);
  mSpeakingTimer.addListener(mSpeedNotifier);
  mSpeakingTimer.addListener(mCaloriesNotifier);
  mStepDetector.addStepListener(mSpeakingTimer);
  reloadSettings();
}
 

Example 92

From project Notes, under directory /src/net/micode/notes/gtask/remote/.

Source file: GTaskASyncTask.java

  15 
vote

public GTaskASyncTask(Context context,OnCompleteListener listener){
  mContext=context;
  mOnCompleteListener=listener;
  mNotifiManager=(NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
  mTaskManager=GTaskManager.getInstance();
}
 

Example 93

From project npr-android-app, under directory /src/org/npr/android/news/.

Source file: PlaybackService.java

  15 
vote

@Override public void onCreate(){
  mediaPlayer=new MediaPlayer();
  mediaPlayer.setOnBufferingUpdateListener(this);
  mediaPlayer.setOnCompletionListener(this);
  mediaPlayer.setOnErrorListener(this);
  mediaPlayer.setOnInfoListener(this);
  mediaPlayer.setOnPreparedListener(this);
  notificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  Log.w(LOG_TAG,"Playback service created");
  telephonyManager=(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
  listener=new PhoneStateListener(){
    @Override public void onCallStateChanged(    int state,    String incomingNumber){
switch (state) {
case TelephonyManager.CALL_STATE_OFFHOOK:
case TelephonyManager.CALL_STATE_RINGING:
        if (isPlaying()) {
          pause();
          isPausedInCall=true;
        }
      break;
case TelephonyManager.CALL_STATE_IDLE:
    if (isPausedInCall) {
      seekTo(Math.max(0,getPosition() - RESUME_REWIND_TIME));
      play();
    }
  break;
}
}
}
;
telephonyManager.listen(listener,PhoneStateListener.LISTEN_CALL_STATE);
}
 

Example 94

From project pandoroid, under directory /src/com/aregner/android/pandoid/.

Source file: PandoraRadioService.java

  15 
vote

@Override public void onCreate(){
synchronized (lock) {
    super.onCreate();
    instance=this;
    pandora=new PandoraRadio();
    media=new MediaPlayer();
    notificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    telephonyManager=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    prefs=PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    telephonyManager.listen(new PhoneStateListener(){
      boolean pausedForRing=false;
      @Override public void onCallStateChanged(      int state,      String incomingNumber){
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
          if (pausedForRing && !media.isPlaying()) {
            if (prefs.getBoolean("behave_resumeOnHangup",true)) {
              media.start();
              setNotification();
              pausedForRing=false;
            }
          }
        break;
case TelephonyManager.CALL_STATE_OFFHOOK:
case TelephonyManager.CALL_STATE_RINGING:
      if (media.isPlaying()) {
        media.pause();
        pausedForRing=true;
      }
    break;
}
}
}
,PhoneStateListener.LISTEN_CALL_STATE);
}
}
 

Example 95

From project phonelocator-android, under directory /phonelocator/src/com/birkettenterprise/phonelocator/service/.

Source file: AudioAlarmService.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  mMediaPlayer=createAndConfigureMediaPlayer(this,R.raw.alarm);
  mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  Log.d(LOG_TAG,"onCreate()");
}
 

Example 96

From project platform_packages_apps_im, under directory /src/com/android/im/service/.

Source file: StatusBarNotifier.java

  15 
vote

public StatusBarNotifier(Context context){
  mContext=context;
  mNotificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  mSettings=new HashMap<Long,Imps.ProviderSettings.QueryMap>();
  mHandler=new Handler();
  mNotificationInfos=new HashMap<Long,NotificationInfo>();
}