質問

How is it possible to wake the application from code?

I am writing a simple timer and when time goes out it displays picture on main activity. But this means that application should stay on screen all the time. If user switches to another app (or simply presses Home) my Activity is no longer visible and I need to show it on screen again (switch back to my application) in the way similar to standard Android Phone or Timer pops up.

So there actually are 2 questions:

  1. How to get application on "top" of screen?
  2. How to correctly display application when screen is locked?
役に立ちましたか?

解決

For that you would need a service that starts your activity when that timer triggers.

You can take a look at the Android Alarm Clock source code for how to have an Activity Shown even on the lock screen: https://github.com/android/platform_packages_apps_alarmclock/blob/master/src/com/android/alarmclock/AlarmAlertFullScreen.java

Note especially lines 85 to 90, here flags are added so that it is allowed to be shown on the Lock Screen. This should of course work with Mono for Android as well.

There is also a nice answer here to your questions: Wake Android Device up It should be fairly easy to port to Mono for Android.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top