Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace calls to setLatestEventInfo, which was removed in android23 API #873

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,25 @@ public int onStartCommand(Intent intent, int flags, int startId) {
pythonThread.start();

Context context = getApplicationContext();
/*
Notification notification = new Notification(context.getApplicationInfo().icon,
serviceTitle,
System.currentTimeMillis());
serviceTitle, System.currentTimeMillis());
*/
Intent contextIntent = new Intent(context, PythonActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
startForeground(1, notification);
PendingIntent.FLAG_UPDATE_CURRENT);
//notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);

Notification.Builder builder = new Notification.Builder(context);
builder.setContentTitle(serviceTitle);
builder.setContentText(serviceDescription);
builder.setContentIntent(pIntent);
builder.setSmallIcon(context.getApplicationInfo().icon);
//builder.setLargeIcon();

Notification notification = builder.build();

startForeground(1, notification);
return START_NOT_STICKY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,24 @@ protected void doStartForeground(Bundle extras) {
String serviceDescription = extras.getString("serviceDescription");

Context context = getApplicationContext();
/*
Notification notification = new Notification(context.getApplicationInfo().icon,
serviceTitle, System.currentTimeMillis());
*/
Intent contextIntent = new Intent(context, PythonActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
//notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);

Notification.Builder builder = new Notification.Builder(context);
builder.setContentTitle(serviceTitle);
builder.setContentText(serviceDescription);
builder.setContentIntent(pIntent);
builder.setSmallIcon(context.getApplicationInfo().icon);
//builder.setLargeIcon();

Notification notification = builder.build();

startForeground(1, notification);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,25 @@ public boolean canDisplayNotification() {
@Override
protected void doStartForeground(Bundle extras) {
Context context = getApplicationContext();
/*
Notification notification = new Notification(context.getApplicationInfo().icon,
"{{ args.name }}", System.currentTimeMillis());
*/
Intent contextIntent = new Intent(context, PythonActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, "{{ args.name }}", "{{ name| capitalize }}", pIntent);
//notification.setLatestEventInfo(context, "{{ args.name }}", "{{ name| capitalize }}", pIntent);
PackageManager pm = context.getPackageManager();

Notification.Builder builder = new Notification.Builder(context);
builder.setContentTitle("{{ args.name }}");
builder.setContentText("{{ name| capitalize }}");
builder.setContentIntent(pIntent);
builder.setSmallIcon(context.getApplicationInfo().icon);
//builder.setLargeIcon();

Notification notification = builder.build();

startForeground({{ service_id }}, notification);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,24 @@ protected void doStartForeground(Bundle extras) {
String serviceDescription = extras.getString("serviceDescription");

Context context = getApplicationContext();
/*
Notification notification = new Notification(context.getApplicationInfo().icon,
serviceTitle, System.currentTimeMillis());
*/
Intent contextIntent = new Intent(context, PythonActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
//notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);

Notification.Builder builder = new Notification.Builder(context);
builder.setContentTitle(serviceTitle);
builder.setContentText(serviceDescription);
builder.setContentIntent(pIntent);
builder.setSmallIcon(context.getApplicationInfo().icon);
//builder.setLargeIcon();

Notification notification = builder.build();

startForeground(1, notification);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,24 @@ public boolean canDisplayNotification() {
@Override
protected void doStartForeground(Bundle extras) {
Context context = getApplicationContext();
/*
Notification notification = new Notification(context.getApplicationInfo().icon,
"{{ args.name }}", System.currentTimeMillis());
*/
Intent contextIntent = new Intent(context, PythonActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, contextIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, "{{ args.name }}", "{{ name| capitalize }}", pIntent);
//notification.setLatestEventInfo(context, "{{ args.name }}", "{{ name| capitalize }}", pIntent);

Notification.Builder builder = new Notification.Builder(context);
builder.setContentTitle("{{ args.name }}");
builder.setContentText("{{ name| capitalize }}");
builder.setContentIntent(pIntent);
builder.setSmallIcon(context.getApplicationInfo().icon);
//builder.setLargeIcon();

Notification notification = builder.build();

startForeground({{ service_id }}, notification);
}

Expand Down