How to get current focus view object in Service?

by mos.chris1...@gmail.com » Tue, 23 Nov 2010 14:49:52 GMT


Sponsored Links
 Dear All,
I want to get the current focus view in my Service to check the view
is a EditText and append some texts in it (for all EditTexts, not only
in my application).

I found some methods to do this, like Activity.getCurrentFocus() and
Windows.getCurrentFocus().
But these methods are used in a Activity.

How can I use these methods in a Service? Or is there another way to
do?

Thanks!

-- 



How to get current focus view object in Service?

by Mos » Tue, 23 Nov 2010 14:51:35 GMT


 Dear All,
I want to get the current focus view in my Service.
And to check if the view is a EditText and append some texts in it
(for all EditTexts, not only in my application).

I found some methods to do this, like Activity.getCurrentFocus() and
Windows.getCurrentFocus().
But these methods are used in a Activity.

If I want to use these, I have to get the current focus activity.
I tried to use WindowManager to get current task.
It only got the current Activity's class name in this way. not
Activity Object.
                List<RunningAppProcessInfo> rList =
activityManager.getRunningAppProcesses();
                RunningTaskInfo rt = rtList.get(0);
                rt.topActivity.getClassName(); // the class name of the current
Activity

How can I use these methods to get the current focus View in a
Service? Or is there another way to
do?

Thanks!

-- 


Sponsored Links


Re: How to get current focus view object in Service?

by TreKing » Wed, 24 Nov 2010 03:46:14 GMT


 On Thu, Nov 18, 2010 at 4:11 AM, mos.chris1...@gmail.com <




Have an activity that binds to your service, tells it when the edit text is
in view and gets a message back from the service.



To listen in on and change text on any other applications' edit texts? Uh
.... no.

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

-- 



Other Threads

1. Audio Playout Delay

Hi,

I am using AudioTrack c++ API to play audio in my system.
There is a latency of around 350ms.

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. Using onCreateDrawableState

Leaving aside the lamentable wording of the documentation for this
method, it's not really acting as I hoped for an ImageView. I call
toggle() from the onClick method of the view but the view system does
not redraw my drawable with the checked state. However, if I
initialize  CHECKED_STATE_SET with android.R.attr.state_checked then
the view is draw with the checked state.

So apparently my call to setImageState is not updating the state of
the ImageView. The documentation for setImageState is totally blank in
the case of an ImageView. What does this mean?

Here's my code:

        private static final int[] CHECKED_STATE_SET =
{android.R.attr.state_empty};

                @Override
                public boolean isChecked() {
                        int[] ds = getDrawableState();
                        return ds[checkedItemIndex] == 
android.R.attr.state_checked;
                }

                @Override
                public void setChecked(boolean isChecked) {
                        int[] ds = getDrawableState();
                        if( isChecked ) {
                                
ds[checkedItemIndex]=android.R.attr.state_checked;
                        } else {
                                ds[checkedItemIndex]=android.R.attr.state_empty;
                        }
                        setImageState(ds,false);
                        refreshDrawableState();
                }

                @Override
                public void toggle() {
                        setChecked( !isChecked() );
                }

                @Override
                public int[] onCreateDrawableState(int extraSpace) {
                        int[] drawableState = 
super.onCreateDrawableState(extraSpace +
CHECKED_STATE_SET.length );
                        checkedItemIndex = drawableState.length - 
CHECKED_STATE_SET.length;
                        mergeDrawableStates( drawableState , CHECKED_STATE_SET 
);
                        return drawableState;
                }

-- 

3. New view for MediaController

4. Webview - Clearing cookies

5. Dialer Calls and app remains visible

6. Unboxing DZ

7. Recorded message