I have two activities A & B. Activity A is launcher activity & I want to Run Activity B in the background when i launch my app. I dont want to go on activity B. I just want to run in background. Also I don't want change this activity to service. My Question is that Can we run a activity in background? if yes then please give me some sample of code how can we run?
Asked
Active
Viewed 69 times
0
-
Why Activity, its any requirement – Lokesh Nov 27 '17 at 07:26
-
3You can't do it. See this answer: https://stackoverflow.com/a/11102383/7011814 – Alex Shevelev Nov 27 '17 at 07:27
-
Describe your problem, please. – Alex Shevelev Nov 27 '17 at 07:28
-
It would be easier to help you if you include any requirements for the problem at hand. – HaroldSer Nov 27 '17 at 07:28
-
Ok.. is there any way to call complete activity in the service class? @AlexShevelev – Zeeshan Arif Nov 27 '17 at 07:38
-
@ScottS I want to run my main activity in the background.. My main activity have a map and i created fences on the map.. when user enter into the fence circle a notification pop up into the device.. Now i want to do a button enable (when user enter) and disable (when user exit) from fence. I dont want to show user a map i just want to show directly an activity which have 3 buttons. I hope now you all can understand which i want.. – Zeeshan Arif Nov 27 '17 at 08:03
-
Main activity functions working perfectly. I just want to run main activity into background not on foreground.. – Zeeshan Arif Nov 27 '17 at 08:05
1 Answers
1
You cannot really run an Activity on background! When an activity is not on foreground it gets to onStop and then the system could terminate it, to release resources, by onDestroy method! see Activity Lifecycle

Lokesh
- 3,247
- 2
- 33
- 62
-
-
https://stackoverflow.com/questions/5015507/how-to-call-an-activity-class-from-a-service-class – Lokesh Nov 27 '17 at 07:46
-
Thank you bro!! Now I want to run complete activity in background through service.. Is there any way or link? – Zeeshan Arif Nov 27 '17 at 07:56
-
I want to run my main activity in the background.. My main activity have a map and i created fences on the map.. when user enter into the fence circle a notification pop up into the device.. Now i want to do a button enable (when user enter) and disable (when user exit) from fence. I dont want to show user a map i just want to show directly an activity which have 3 buttons. I hope now you all can understand which i want.. – Zeeshan Arif Nov 27 '17 at 08:03
-
Nope, But my question why activity, activity is create for foreground, iyou can use service, asynctask or job for background when your task is finish get call back in Activity – Lokesh Nov 27 '17 at 08:04
-
You are asking for wrong thing, when you set notification set callback activity that you want to show – Lokesh Nov 27 '17 at 08:11
-
First mine task was to show on activity that's why i created activity now his new requirement this main activity should be invisible for user.. – Zeeshan Arif Nov 27 '17 at 08:13
-
Yes thanks you got my point.. But how to invisible main activity for user?? – Zeeshan Arif Nov 27 '17 at 08:15
-
-
-
https://zeeshanfuuastcs.blogspot.com/b/post-preview?token=xpOU_l8BAAA.QY4mu8RCROkG_xLQQ1F-uxI3pEYiAbXo9yKZalNnIUieIuBuvusq5QPIph36Ksc8ztQ0tOHylRehNceYliRYlw.uQfiBs4WjJY4_HZ0BNIMfw&postId=2852912898695631903&type=POST – Zeeshan Arif Nov 27 '17 at 09:45
-