StatusBarView.java这个类有两个重要的方法, onTouchEvent和onInterceptTouchEvent 这两个方法主要是用来响应statusbar的下拉事件,使之能显示扩展的状态栏。 StatusBarService.java有个内部类,Launcher,该类中有个方法onClick: public void onClick(View v) { try { // The intent we are sending is for the application, which // won't have permission to immediately start an activity after // the user switches to home. We know it is safe to do at this // point, so make sure new activity switches are now allowed. ActivityManagerNative.getDefault().resumeAppSwitches(); } catch (RemoteException e) { }
if (mIntent != null) { int[] pos = new int[2]; v.getLocationOnScreen(pos); Intent overlay = new Intent(); overlay.setSourceBounds( new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); try { mIntent.send(StatusBarService.this, 0, overlay); } catch (PendingIntent.CanceledException e) { // the stack trace isn't very helpful here. Just log the exception message. Slog.w(TAG, "Sending contentIntent failed: " + e); } }
try { mBarService.onNotificationClick(mPkg, mTag, mId); } catch (RemoteException ex) { // system process is dead if we're here. }
// close the shade if it was open animateCollapse(); } }感觉mBarService.onNotificationClick(mPkg, mTag, mId);这个方法应该就是处理按键消息的。只不过没用到上层传过来的contentIntent参数。搞不懂了
PendingIntent contentIntent = PendingIntent.getActivity(this,0,notificationIntent,0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
nf.notify(0, notification);
那么,点击statusbar对应的图标时,具体的按键响应过程是怎么样的呢?
StatusBarView.java
StatusBarService.java
onTouchEvent和onInterceptTouchEvent
这两个方法主要是用来响应statusbar的下拉事件,使之能显示扩展的状态栏。
StatusBarService.java有个内部类,Launcher,该类中有个方法onClick: public void onClick(View v) {
try {
// The intent we are sending is for the application, which
// won't have permission to immediately start an activity after
// the user switches to home. We know it is safe to do at this
// point, so make sure new activity switches are now allowed.
ActivityManagerNative.getDefault().resumeAppSwitches();
} catch (RemoteException e) {
}
if (mIntent != null) {
int[] pos = new int[2];
v.getLocationOnScreen(pos);
Intent overlay = new Intent();
overlay.setSourceBounds(
new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight()));
try {
mIntent.send(StatusBarService.this, 0, overlay);
} catch (PendingIntent.CanceledException e) {
// the stack trace isn't very helpful here. Just log the exception message.
Slog.w(TAG, "Sending contentIntent failed: " + e);
}
}
try {
mBarService.onNotificationClick(mPkg, mTag, mId);
} catch (RemoteException ex) {
// system process is dead if we're here.
}
// close the shade if it was open
animateCollapse();
}
}感觉mBarService.onNotificationClick(mPkg, mTag, mId);这个方法应该就是处理按键消息的。只不过没用到上层传过来的contentIntent参数。搞不懂了
我想问我下拉了通知栏点击后成功连到了另一个class但是此时上面的那个通知栏还是显示着自己的提示。请问我想做到拉下来后点击连接到另个class后上面的提示也消失怎么做?
我想问我下拉了通知栏点击后成功连到了另一个class但是此时上面的那个通知栏还是显示着自己的提示。请问我想做到拉下来后点击连接到另个class后上面的提示也消失怎么做?将发出来的notification的flags设置为FLAG_AUTO_CANCEL就可以啦