Tag: 通知

以编程方式使用辅助function服务读取通知栏标题,消息

使用辅助function服务我能够阅读通知栏标题和消息,我面临的问题是当第一次通知出现时我正在完美地阅读所有这些但是在第一次通知后,我只获得标题和文本“你有2条消息”等等,而不是整个消息。 等待你的专家意见。 代码: @Override protected void onServiceConnected() { Log.d(“AccessibilityServiceNotification”, “ServiceConnected”); try { AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.feedbackType = AccessibilityServiceInfo.FEEDBACK_ALL_MASK; info.notificationTimeout = 100; setServiceInfo(info); } catch(Exception e) { Log.d(“ERROR onServiceConnected”, e.toString()); } } @Override public void onAccessibilityEvent(AccessibilityEvent event) { try { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); Parcelable data = event.getParcelableData(); if(data !=null) […]

如何区分等待(长时间超时)退出通知或超时?

有这个等待声明: public final native void wait(long timeout) throws InterruptedException; 它可以通过InterruptedException或超时退出,或者因为在另一个线程中调用Notify / NotifyAll方法,Exception很容易捕获但是…… 有什么方法可以知道退出原因是超时还是通知? 编辑: 这是一个可行的棘手方式,(虽然我不喜欢它) long tBefore=System.currentTimeMillis(); wait(TIMEOUT); if ((System.currentTimeMillis() – tBefore) > TIMEOUT) { //timeout }

java中的滑动通知栏(一个火狐)

我想在我的java应用程序的Firefox或IE中实现一个滑动通知栏。 但我不想重新发明轮子,我相信那里的人已经做过并且愿意分享。 你知道java / swing中的任何开源实现吗?

在Integer上同步时对notify()的IllegalMonitorStateException

我刚接触在Java中使用wait()和notify(),我得到一个IllegalMonitorStateException。 主要代码 public class ThreadTest { private static Integer state = 0; public static void main(String[] args) { synchronized(state) { System.out.println(“Starting thread”); Thread t = new Thread(new AnotherTest()); t.start(); synchronized(state) { state = 0; while(state == 0) { try { state.wait(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } System.out.println(“State […]

Java线程:等待并通知方法

我有一个调用wait方法的线程,只能在从其他类调用notify方法时唤醒: class ThreadA { public static void main(String [] args) { ThreadB b = new ThreadB(); b.start(); synchronized(b) { try { System.out.println(“Waiting for b to complete…”); b.wait(); } catch (InterruptedException e) {} System.out.println(“Total is: ” + b.total); } } } class ThreadB extends Thread { int total; public void run() { synchronized(this) { for(int i=0;i<100;i++) […]

如何在swing中创建通知

使用Java和Swing,是否有任何(方便)方法来创建通知? 通知,我的意思是: 这http://productivelinux.com/images/notify-osd-screenshot.png , 这是http://images.maketecheasier.com/2010/01/kfirefox-notify-indexed.png ,或者 (那是否有更正确的术语?)。 如果它跨平台工作会很好,但我主要关心它在Ubuntu和Gnome一起工作。 如果可能的话,我想避免在系统托盘/通知区域中有一个图标。 如果所有其他方法都失败了,我总是可以使用java中的滑动通知栏中的滑动通知(一个火狐)

按顺序java运行3个线程

我有3个线程第1次打印第2次打印B第3次打印C. 我想按顺序打印ABCABCABC等等…… 所以我在下面编写了这个程序,但我无法实现同样的目标。 我知道当status = 1时,例如B1和C1线程正在等待,当我执行notifyAll()时,两个等待线程都被唤醒,并且根据CPU分配,它可能会打印B或C. 在这种情况下,我只想在A之后打印B. 我需要做什么修改。 public class NotifyAllExample { int status=1; public static void main(String[] args) { NotifyAllExample notifyAllExample = new NotifyAllExample(); A1 a=new A1(notifyAllExample); B1 b=new B1(notifyAllExample); C1 c=new C1(notifyAllExample); a.start(); b.start(); c.start(); } } class A1 extends Thread{ NotifyAllExample notifyAllExample; A1(NotifyAllExample notifyAllExample){ this.notifyAllExample = notifyAllExample; } @Override public void run() […]