Home Screen Detection

by GodsMoon » Fri, 28 Aug 2009 05:43:24 GMT


Sponsored Links
 I'm writing a back ground app and would like to be able to tell which
app is currently running (actually has focus).
I'm particularly interested in if the Home screen is being shown.
Can anyone help with this?
--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by GodsMoon » Fri, 28 Aug 2009 06:25:25 GMT


 That might be enough info for my app.
Which api are you looking at?





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Home Screen Detection

by Chris Stratton » Fri, 28 Aug 2009 08:23:50 GMT


 


I got stumped on that too.

There is a call that will get a list of what is running and tell if it
has user-interactive level of priority, but that's not unique enough -
a few things (in call screen for example) keep this even when their
window is not visible.  Another problem is that latin input method can
show up in the list interactive priority, but you don't know what
application it is accepting input on behalf of.
--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by Hong » Sat, 29 Aug 2009 01:47:44 GMT


 ActivityManager : getRunningTasks(int)





--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by GodsMoon » Sat, 29 Aug 2009 01:49:21 GMT


 I was looking at the Package Manager api, but it looks like the
Process api might be more useful.
 http://developer.android.com/reference/android/os/Process.html 
Has anybody used this before or have an example?





--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by GodsMoon » Sat, 29 Aug 2009 01:54:49 GMT


 What's the difference between a Task and a Process for
ActivityManager?




--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by Dianne Hackborn » Sat, 29 Aug 2009 02:42:07 GMT


 They are described here:
 http://developer.android.com/guide/topics/fundamentals.html 








-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by GodsMoon » Sun, 30 Aug 2009 01:00:53 GMT


 I have a solution for home screen detection, but its slow and
horrible.
I run this bit of code every 1 seconds.

ActivityManager actvityManager = (ActivityManager)
this.getSystemService( ACTIVITY_SERVICE );
                List<RunningAppProcessInfo>  procInfos =
actvityManager.getRunningAppProcesses();

                for(int i = 0; i < procInfos.size(); i++)
                {

                        if(procInfos.get(i).processName.compareTo
( "android.process.acore") == 0
                                        && procInfos.get(i).importance ==
RunningAppProcessInfo.IMPORTANCE_FOREGROUND)
                        {

                                // Home Screen Detected! Do something...
                        }

                }

I hate continually polling a piece of code but I don't think there is
a broadcast intent that will help me out.

Do anybody know of a better way of doing this?






--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by Dianne Hackborn » Sun, 30 Aug 2009 02:36:58 GMT


 No there is no API to do this.  What are you trying to accomplish?

Note that your code will break in many many situations -- when a custom home
screen is being used, on a device where the manufacturer is not using the
base platform home app, in the future when we have more memory so don't need
to run home in a shared process, etc.










-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by GodsMoon » Sun, 30 Aug 2009 02:53:30 GMT


 'm writing an app that turns off the keyguard and I would like to
exitKeyguardSecurely when you user goes back to the home screen.
This works great when hitting the Home button, but the user can back
to the home screen without prompt by using the back button (I think
this is an API bug).
So I'm trying to determine if the Home screen is displayed so I can
force exitKeyguardSecurely.

I realize homescreen replacements will break this code but until the
API bug gets fixed I don't see a good way around this.

On Aug 29, 2:35pm, Dianne Hackborn <hack...@android.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by Dianne Hackborn » Sun, 30 Aug 2009 03:56:34 GMT


 




What API bug?  Of course you can press back to go to the home screen.

What are you doing to determine when the user presses home?  Afaik there
isn't really a way to do this since the system completely consumes the home
key.

Unfortunately, I don't think there is any robust way to do what you want.  I
can't imagine an app being able to do this consistently with the current
API...  and that should kind-of give you a moment of pause since you are
messing with the lock screen and thus fundamental security of the device.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by GodsMoon » Sun, 30 Aug 2009 04:31:30 GMT


 Dianne Hackborn,
Are you familiar with the KeyguardManager class? Its really cool, I
haven't seen anything like it on any other platform and I'm excited to
take advantage of it.
 http://developer.android.com/reference/android/app/KeyguardManager.html 

It can take over the Home screen button

I've created a bug report.
 http://code.google.com/p/android/issues/detail?id=3715 

Thanks for your help.






--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by Dianne Hackborn » Sun, 30 Aug 2009 07:40:59 GMT


 




Yes I am.




I don't know what you mean.  As far as I know, it has nothing to do with the
home screen button, it just controls whether the lock screen is shown.




I've closed this as work as intended, because what you are requesting is not
how it is supposed to work.

You could look at the AlarmClock app to see an example if the API's use.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by GodsMoon » Sun, 30 Aug 2009 09:24:49 GMT


 I admit that what I'm trying to do is a little unorthodox and somewhat
creative. The idea I have does slightly change the way security works
on the phone. However, I don't think I'm abusing the API or decreasing
security. Its somewhat hard to explain my app idea. I will be
releasing a video of my app in action for the ADC2 fairly soon.
I'll post back here once it is released the video. I'd love to get
feedback to make sure I'm not doing anything I'm not suppose to.

Thanks for your help.





--~--~---------~--~----~------------~-------~--~----~



Home Screen Detection

by Hong » Fri, 04 Sep 2009 05:49:14 GMT


 I found the video:
 http://www.youtube.com/watch?v=ipue9Yhi5VA 

NICE WORK!





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. how to open an App when the Android OS start up

Hi,

Sure, there is a way. Android broadcasts a special intent action once booting is completed. In your manifest: 1. Add a permission to receive the event: <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 2. Declare a broadcast receiver: <receiver android:name="your receiver name here" android:label="@string/boot_receiver_name"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> 3. In the receiver's onReceive method, check the action and do what's needed: @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_BOOT_COMPLETED)) { /* * Boot completed, start the activity */ } } -- Kostya 14.06.2010 14:43, CMF :
hi all, is there any one know how to open an App when the Android OS start up, I have to do it in an embedded system?
-- Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com --

2. how to change an icon of the Tabhost at run time

Hello all,

I have added a tabs using Tab host  and when i get an event from a
service i wanted to change an icon of one of the tabs. I don't see any
methods of doing the same. Can you let me know how its being done.

~titus

-- 

3. Google's global quick search widget missing in Android 2.2

4. Performance problem with large Bitmap

5. What is Wild (N) for in Contact Number composer?

6. Annoying ADB Bus Error

7. How the Bluetooth AG work?