Hi Dianne and Joe,
As per our previous discussion I used a sticky broadcast for the dock
state.
However, at the receiver end I am getting the intent twice
Here are the relevant code snippets and logs. You can see that Dock
State:1 received is printed twice.
Broadcast -
----------------------------------------------------------------------------------------------------------
mDockIntent.putExtra(Intent.EXTRA_DOCK_STATE, DOCKED_DESK);
mContext.sendStickyBroadcast(mDockIntent);
Log.d(TAG, "Dock State Broadcast : DOCKED_DESK: "+DOCKED_DESK);
----------------------------------------------------------------------------------------------------------
Receiver -
BroadcastReceiver dockBroadcastReceiver = new BroadcastReceiver
(){
@Override
public void onReceive(Context context, Intent intent) {
String intentAction = intent.getAction();
if (intentAction.equals(DOCK_EVENT)) {
int extra = intent.getIntExtra(DOCK_EXTRA, 0);
Log.d("DEBUG", "Dock State:"+extra+" received");
mTextView.setText("Dock State:"+extra+"
received");
}
}
};
----------------------------------------------------------------------------------------------------------
Resulting log -
D/WindowManager( 53): Dock State Broadcast : DOCKED_DESK: 1
D/DEBUG ( 280): Dock State:1 received
I/WindowManager( 53): Input configuration changed: { scale=1.0
imsi=0/0 locale=en_US touch=3 key=2/1/2 nav=3 orien=2 }
D/KeyguardViewMediator( 53): pokeWakelock(10000)
V/ActivityThread( 280): Resuming ActivityRecord{436f7240
token=android.os.BinderProxy@436f6d28 {com.somecompany.docktest/
com.somecompany.docktest.DockTest}} with isForward=true
D/DEBUG ( 280): Dock State:1 received
D/StatusBar( 53): updateResources
D/dalvikvm( 53): GC freed 1029 objects / 46408 bytes in 95ms
----------------------------------------------------------------------------------------------------------
On Feb 20, 6:12 pm, naseer <
naseer.ah...@gmail.com> wrote:
> PhoneWindowManager.interceptKeyTi does not get a raw event. Dock
> events are raw input events of type EV_SW. Hence I am back to using
> preprocessInputEventTq.
> I am also sending it in readDockState (which is the same as
> readLidState) if the previous state is different.
>
> Thanks,
> -Naseer
>
> On Feb 20, 2:27 am, Joe Onorato <
j...@android.com> wrote:
>
> > What Dianne said. IIRC, the runnable there is to handle long press for the
> > ACTION_MEDIA_BUTTON.
>
> > -joe
>
> > On Thu, Feb 19, 2009 at 1:06 PM, Dianne Hackborn <
hack...@android.com>wrote:
>
> > > Nope there shouldn't be any need for that. Just do the broadcast when you
> > > get the event.
>
> > > On Thu, Feb 19, 2009 at 12:19 PM,Naseer<
naseer.ah...@gmail.com> wrote:
>
> > >> Thanks Dianne and Joe for your quick response.
> > >> Joe - would you suggest putting the stickyBroadcast in a separate
> > >> runnable as is done for .ACTION_MEDIA_BUTTON in the same class ?
>
> > >> On Feb 20, 1:04 am, Joe Onorato <
j...@android.com> wrote:
> > >> > On Thu, Feb 19, 2009 at 11:57 AM,Naseer<
naseer.ah...@gmail.com>
> > >> > > > On Thu, Feb 19, 2009 at 4:32 AM,Naseer<
naseer.ah...@gmail.com>
> > >> > > > > > On Fri, Feb 13, 2009 at 9:12 PM,Naseer<
naseer.ah...@gmail.com