Repository navigation
Closed
Description
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
Labels
No labels
Activity
agaleazzi commentedon Feb 23, 2018
I've got the same issue
lufebe16 commentedon May 18, 2018
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 commentedon Jan 30, 2019
Closing as (I think) resolved.
AndreMiras commentedon Feb 8, 2019
I confirm we now have a try/catch on
notification.getClass().getMethod("setLatestEventInfo"....and fallback to other mechanisms