2014-11-14 106 views
1

我使用通知侦听器API来读取通知信息,但似乎无法读取Gmail通知的文本。这里adb说:无法读取Gmail通知

extras={ 
     android.title=john 
     android.support.actionExtras={0=Bundle[EMPTY_PARCEL], 1=Bundle[EMPTY_PARCEL]} 
     [email protected] 
     android.showChronometer=false 
     android.icon=2130837727 
     android.text=MyText 
     android.progress=0 
     android.progressMax=0 
     android.showWhen=true 
     android.people=[Ljava.lang.String;@b1564718 { 
      mailto:[email protected] 
     } 
     [email protected] (128x128) 
     android.infoText=null 
     android.wearable.EXTENSIONS=Bundle[mParcelledData.dataSize=1200] 
     android.progressIndeterminate=false 
     android.scoreModified=false 
     } 

与其他通知它的工作。有小费吗?我以这种方式阅读通知:

String text = extras.getString(Notification.EXTRA_TEXT); 

回答

1

好的问题解决了。有关通知的信息存储为CharSequence所以你必须得到getCharSequence()。由于String实现了CharSequence接口,它可能会工作,但并非总是如此。然而,使用CharSequence它的作品。