Reputation: 16622
I want to develop a program which reminds word (english-turkish). The things what I have to do below and please correct me if I'm wrong or bad way I'm using.
Main.java
class as an activity which includes a textview to show english word SharedPreferences
MyService
name. SharedPreferences
inside the OnCreate method of MyService
.New Word
use the service's function to connect and retrieve new word and show in TextView in Main activityOk
set Activity to Pause mode and show Home ScreenI have some difficulties to Resume Main activity and passing new word.
Do you know a way to bring front Main activity periodically while it is in resume state?
Upvotes: 0
Views: 2234
Reputation: 12636
There is no difference between starting activity and bringing them to foreground - read about activity lifecycle. Service is ineffective if you want to use it as simple timer. Much better approach is to use AlarmManager and scheduling next activity start. Here you have an example. Then just override Activity.onStart() method, to fill all fields you want.
Upvotes: 0
Reputation: 4448
Try to make an intent in the onResume() call with this flag: FLAG_ACTIVITY_REORDER_TO_FRONT which causes the launched activity to be brought to the front..
For more information click here.
Upvotes: 1