Skip to content

Issue with Android API 23+ #1231

@saband

Description

@saband

Notification.setLatestEventInfo is removed in API Level 23 (Android 6.0)
https://developer.android.com/sdk/api_diff/23/changes/android.app.Notification.html
but still in use in PythonService.java and Service.tmpl.java:

protected void doStartForeground(Bundle extras) {
        String serviceTitle = extras.getString("serviceTitle");
        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);
        startForeground(1, notification);
    }
@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);
        startForeground({{ service_id }}, notification);
    }

This leads to error:

src/main/java/org/kivy/android/PythonService.java:97: error: cannot find symbol
        notification.setLatestEventInfo(context, serviceTitle, serviceDescription, pIntent);
                    ^
  symbol:   method setLatestEventInfo(Context,String,String,PendingIntent)
  location: variable notification of type Notification
  location: variable notification of type Notification	
Note: Some input files use or override a deprecated API.	
Note: Recompile with -Xlint:deprecation for details.	
1 error	
:compileDebugJavaWithJavac FAILED

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions