Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NotificationListenerService和低于18的Android版本会发生什么_Android - Fatal编程技术网

NotificationListenerService和低于18的Android版本会发生什么

NotificationListenerService和低于18的Android版本会发生什么,android,Android,我有一个扩展NotificationListenerService的应用程序,它是API 18+。它在AndroidStudio中使用MinsdkVersion16编译,这很好。如果忽略它并不重要,因为我只是用它来清除通知,但是在17个版本中,它会崩溃还是忽略?我没有低版本的手机要测试,也不能使用模拟器,因为它涉及蓝牙 更新:使用 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) 以上方法和步骤 if (android.os.Build.VERSIO

我有一个扩展NotificationListenerService的应用程序,它是API 18+。它在AndroidStudio中使用MinsdkVersion16编译,这很好。如果忽略它并不重要,因为我只是用它来清除通知,但是在17个版本中,它会崩溃还是忽略?我没有低版本的手机要测试,也不能使用模拟器,因为它涉及蓝牙

更新:使用

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
以上方法和步骤

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
    ... Various code fragments.
}

我测试的Jelly Bean设备工作正常。

系统不会调用您的
NotificationListenerService
(显然,它不知道它是什么)。但是,如果您自己手动启动该服务,则您的应用程序将因找不到超类而崩溃