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. Supplying a different background drawable for a dialog?

Hi,

I'm trying to supply my own background drawable for a dialog. It works
fine on 1.6+, on 1.5 though instead of a transparent dimmed background
around the dialog, I just get opaque black. I defined the style like
this in my styles.xml file:

   <style name="CustomDlg" parent="@android:style/Theme.Dialog">
     <item name="android:windowBackground">@drawable/my_background</
item>
   </style>

Is there something else we need to do so that we can still get the
transparency around the dialog? The drawable is nothing special, I
just took the stock one from the aop and changed the color on the
inside of the frame.

Thanks

-- 

2. How to reset the price of application

Hi fellow developers.
Recently I tried to temporary set the price of one of my apps to Free,
just to see the boost in downloads. However now I cannot re-set it,
there is simply no radio button to switch to price. Is there some
workaround for this? I cannot delete application from developer
console and just reupload same application once more, already tried
that.

Thanks for any ideas,
Rudo

-- 

3. How to manage orientation dependent activities?

4. Asyik bloo bisa chat

5. How to use built in email application to send email from my application

6. How to use built in email application to send email from my application

7. MiFi : mahalkah android ?