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

Issue with Android API 23+ #1231

Closed
saband opened this issue Feb 8, 2018 · 4 comments
Closed

Issue with Android API 23+ #1231

saband opened this issue Feb 8, 2018 · 4 comments

Comments

@saband
Copy link

saband commented Feb 8, 2018

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
@agaleazzi
Copy link

I've got the same issue

@lufebe16
Copy link

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.

@inclement
Copy link
Member

Closing as (I think) resolved.

@AndreMiras
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants