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. Pindah memopad dari BB + lock setting Androi

DI bb  install notepad dulu.  memopadnya disimpan via notepad, nadu dikopi
ke men android

Sent from Rooted Nengdroid 1 Broadband




ternyata memopad ga bisa dicopy..
Ada yang bisa bantu?


-- 
"Indonesian Android Community [id-android]"

2. Question about the Lsit View

Hi i'm new on this forum, i searched for a way to make "divs" in my
android apps but i cant find any post of this theme, so i post what i
want to do here:

------------------------
|        Text View |   not scrollbable
------------------------
|   List               |  Scrollbable
------------------------
| Button1Button2| not scrollbable
-------------------------

Also when i try to make a 1.6 android application, whit this code:

HelloList.java

package com.examples;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class HelloList extends ListActivity {
    private String[]
COUNTRIES=getResources().getStringArray(R.array.countries_array);;

        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        this.setListAdapter(new ArrayAdapter<String>(this,
R.layout.list_item, COUNTRIES));
        ListView lv = getListView();
        lv.setTextFilterEnabled(true);

        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                  // When clicked, show a toast with the TextView text
                  Toast.makeText(getApplicationContext(), ((TextView)
view).getText(),
                      Toast.LENGTH_SHORT).show();
                }
              });

    }
}


res/values/valores.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="countries_array">
        <item>Bahrain</item>
        <item>Bangladesh</item>
        <item>Barbados</item>
        <item>Belarus</item>
        <item>Belgium</item>
        <item>Belize</item>
        <item>Benin</item>
    </string-array>
</resources>

res/values/string.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, HelloList!</string>
    <string name="app_name">Hola Lista</string>
</resources>

res/values/list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp"
    android:textSize="16sp" >
</TextView>

res/values/main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
</LinearLayout>

-- 

3. Reminder: Seminar/Launching X10 and Gathering id-android

4. Prevent Orientation change at runtime

5. Pindah memopad dari BB + lock setting Androi

6. Looped ListView

7. HELP! Magic ga mau booting