Thursday, February 20, 2014

How android notification bar click on the icon in response to events


After the pull down Status bar, you can click on the corresponding above icon, so as to bring up the appropriate Activity.
Will this process is how to achieve? Or, specifically what kind of reaction the key event to make<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
I wrote a small apk, in order to achieve the specified application starts in a Activity, only need to know the current context and Activity can be.
 
Intent notificationIntent = new Intent (this, this.getClass ()); / / click on the notification to jump Activity
PendingIntent contentIntent = PendingIntent.getActivity (this, 0, notificationIntent, 0);
notification.setLatestEventInfo (context, contentTitle, contentText, contentIntent);
nf.notify (0, notification);


Then, click on the corresponding icon statusbar specific key response process is kind of how it?
Reply:
Landlord look frameworks / base / services / java / com / android / server / status /
StatusBarView.java
StatusBarService.java
Reply:
reference to the second floor qiying1988 reply:
landlord facie frameworks / base / services / java / com / android / server / status /
StatusBarView.java
StatusBarService.java

StatusBarView.java This class has two important methods,
onTouchEvent and onInterceptTouchEvent
These two methods are used mainly in response to the drop-down event statusbar and extended so that it can display the status bar.
StatusBarService.java there is an inner class, Launcher, the class has a method 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 ();
}
}

Feeling mBarService.onNotificationClick (mPkg, mTag, mId); This method should handle the key message is. But useless to the upper pass over contentIntent parameters. Do not understand
Reply:
Read the reply should first reply?
Reply:
Learn
Reply:
Novice learning to come.
I would like to pull down the notification bar, I clicked successfully connected to another class, but this time above the notification bar or display their own tips. Will I want to be pulled down after clicking on the link to the above tips have disappeared after another a class how to do?
Reply:
cancel out
references 6th Floor devil_ling reply:
Newbie, learning came.
I would like to pull down the notification bar, I clicked successfully connected to another class, but this time above the notification bar or display their own tips. Will I want to be pulled down after clicking on the link to the above tips have disappeared after another a class how to do?

Reply:
Novice learning to come.
I would like to pull down the notification bar, I clicked successfully connected to another class, but this time above the notification bar or display their own tips. Will I want to be pulled down after clicking on the link to the above tips have disappeared after another a class how to do?

The notification will be sent to the flags set FLAG_AUTO_CANCEL can be friends
Reply:
reference to the second floor of the reply:
landlord facie frameworks / base / services / java / com / android / server / status /
StatusBarView.java
StatusBarService.java



mBarService.onNotificationClick (mPkg, mTag, mId) This method is to inform notificationManagerService clear notification

Reply:
Passing, look, look

No comments:

Post a Comment