gpt4 book ai didi

android - 为什么我的 NotificationListenerService 不工作?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:27:56 25 4
gpt4 key购买 nike

我已经实现了 NotificationListenerService,但它不工作。这是服务:

public class NotificationListener extends NotificationListenerService {

@Override
public void onCreate() {
Log.d("MYAPP", "Created");
}

@Override
public IBinder onBind(Intent intent) {
return null;
}

@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.d("MYAPP", "Notification");
}

}

我已经在我的 list 文件中实现了这个:

<service android:name="com.rodrigopontes.whatsappbubbles.NotificationListener"
android:label="Test"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>

这是我从 MainActivity 初始化它的方式:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
startService(new Intent(this, NotificationListener.class));
}

谢谢你的帮助!

最佳答案

在浪费了许多时间之后,我找到了这个问题的答案。这是 Android 的问题,请参阅 here欢迎使用 Android :)

关于android - 为什么我的 NotificationListenerService 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32570505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com