Skip to content

Issue with Android API 23+ #1231

Closed
Closed

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

Activity

  1. agaleazzi commented on Feb 23, 2018

    @agaleazzi

    I've got the same issue

  2. lufebe16 commented on May 18, 2018

    @lufebe16

    In order to compile for arm64-v8a I also tried api 23 (instead of usually 19). I have the same problem. It occurs also for armeabi-v7a.

  3. inclement commented on Jan 30, 2019

    @inclement
    Member

    Closing as (I think) resolved.

  4. AndreMiras commented on Feb 8, 2019

    @AndreMiras
    Member

    I confirm we now have a try/catch on notification.getClass().getMethod("setLatestEventInfo".... and fallback to other mechanisms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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