Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
309 views
in Technique[技术] by (71.8m points)

Waking up my android app from background into the main screen programatically

I am trying to make a taxi driver app that lets me wake the phone and directly open the app from the background whenever I get an fcm notification. What do we call this feature? and how can I implement it on android using java? I found many implementations but they all do it when clicking on notifications.

An explanation for the "it's a bad behavior" argument: "This is a driver side taxi app that really needs the quick response on notification because it has a timeout feature built-in. and I can ensure that all drivers have signed physical contracts that include this feature as a clause"

question from:https://stackoverflow.com/questions/66047272/waking-up-my-android-app-from-background-into-the-main-screen-programatically

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You may go through following steps:

  1. Start a Foreground Service (that always run in background )
  2. In Your Service Class catch Your Event(like you said fcm notification) and start your app activity.( Rather you should alert user with alarm tone or on-screen Dialog

Here's an wonderful example that uses a background service(you may change it into a foreground service) to show a fragment on lockscreen hope this will help you know how and where to start.

and also it's not a bad behavior cause the notification panel will always show that your foreground service is running untill and unless user himself turn notifications off your app


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...