Bug 1208587 - SUTAgent: Replace deprecated Notification APIs with Notification.Builder. r=mcomella

--HG--
extra : commitid : Bdpz74Cg3YE
extra : rebase_source : 20d826131ad64252df53b16392d08d0be60f7c19
This commit is contained in:
Sebastian Kaspari 2015-10-05 10:51:18 +02:00
parent 00ecc8cd66
commit 45525f962d
2 changed files with 25 additions and 16 deletions

View File

@ -915,20 +915,24 @@ public class DoCommand {
int icon = R.drawable.ateamlogo;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
notification.flags |= (Notification.FLAG_INSISTENT | Notification.FLAG_AUTO_CANCEL);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
Context context = contextWrapper.getApplicationContext();
// Intent to launch an activity when the extended text is clicked
Intent intent2 = new Intent(contextWrapper, SUTAgentAndroid.class);
PendingIntent launchIntent = PendingIntent.getActivity(context, 0, intent2, 0);
notification.setLatestEventInfo(context, tickerText, expandedText, launchIntent);
Notification notification = new Notification.Builder(context)
.setContentTitle(tickerText)
.setContentText(expandedText)
.setSmallIcon(icon)
.setWhen(when)
.setContentIntent(launchIntent)
.build();
notification.flags |= (Notification.FLAG_INSISTENT | Notification.FLAG_AUTO_CANCEL);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notificationManager.notify(1959, notification);
}

View File

@ -222,20 +222,25 @@ public class RunCmdThread extends Thread
int icon = R.drawable.ateamlogo;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
notification.flags |= (Notification.FLAG_INSISTENT | Notification.FLAG_AUTO_CANCEL);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
Context context = svc.getApplicationContext();
// Intent to launch an activity when the extended text is clicked
Intent intent2 = new Intent(svc, SUTAgentAndroid.class);
PendingIntent launchIntent = PendingIntent.getActivity(context, 0, intent2, 0);
notification.setLatestEventInfo(context, tickerText, expandedText, launchIntent);
Notification notification = new Notification.Builder(context)
.setSmallIcon(icon)
.setContentTitle(tickerText)
.setContentText(expandedText)
.setContentIntent(launchIntent)
.setWhen(when)
.build();
notification.flags |= (Notification.FLAG_INSISTENT | Notification.FLAG_AUTO_CANCEL);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notificationManager.notify(1959, notification);
}