0

I'm trying to build an application that would run at the same time as another one, on top of it (hiding only partially the original app), that would display useful information for the user of the main app. But it seems that 2 activities cannot run at the same time, overlap, etc...

For argument sake, lets say the app would be displaying date & time in a corner of the screen, while playing a specific game.

Anyone got any doc or sample code on how to achieve such a result ?

I'm also interested in how to know which app is currently running in order to decide in my app-on-top to be visible or invisible.

Any help appreciated :) Thx

user2935731
  • 1
  • 1
  • 1
  • 1
    two app or two activity – Shakeeb Ayaz Oct 30 '13 at 10:01
  • do you need another app for displaying date and time??? – Linga Oct 30 '13 at 10:06
  • what u are telling u can do that in same activity by changing time conitiously – Shakeeb Ayaz Oct 30 '13 at 10:09
  • Perhaps what you want is kind of overlay activity that draws over current activity? – Andrew T. Oct 30 '13 at 10:12
  • I think I've not been clear enough, the main app is an already existing application, not created by me. On top of it I'd like to display some useful information for the user of this specific application. (Time & date is only an example to start discussing the technical issue, that's not the point of my app) – user2935731 Oct 30 '13 at 10:27

3 Answers3

0

The Android system is designed to be user friendly, and two activities at same time is not, so only one activity is on foreground at once. if you need the other to be running in background make it a Service, if you want to show some data and get back first one use a Dialog, finally if you want both you can either put them in one activity or use Fragments as @Tooroop suggsets.

Ahmad Dwaik 'Warlock'
  • 5,953
  • 5
  • 34
  • 56
  • I guess I need to look into Services to have my app run in background then. Can a service display a UI ? Only temporary popups or can it be a full time display overlaying ? – user2935731 Oct 30 '13 at 10:30
  • I think services can't show on ui, however they can send notification to the top notifican bar – Ahmad Dwaik 'Warlock' Oct 30 '13 at 10:32
  • hmm... I was also thinking about widgets but I think it would be OK only if the main app is a widget receiver, and I'm pretty sure it's not. – user2935731 Oct 30 '13 at 10:43
0

Looks like you are in need of Fragments: Fragments

Tooroop
  • 1,824
  • 1
  • 20
  • 31
  • Fragments would make sense if I owned both app, but I dont. – user2935731 Oct 30 '13 at 10:29
  • If the other applications uses a content provider I think you could have access to that data from your other application, and you could show it in the top fragment. If you can change your first application you could create a content resolver for that purpose. – Tooroop Oct 30 '13 at 10:42
  • Can I fully run a third party full-screen app inside one fragment and display some info into another fragment ? Seems unlikely... – user2935731 Oct 30 '13 at 10:58
  • But maybe I could check a bit this kind of stuff although that seems tricky : http://stackoverflow.com/questions/18933320/always-show-some-widgets-on-the-top-of-all-activity – user2935731 Oct 30 '13 at 10:58
  • no, I dont think it's possible to run 2 separate applications in one screen. – Tooroop Oct 30 '13 at 11:10
  • Even if I use TYPE_SYSTEM_OVERLAY ? – user2935731 Oct 30 '13 at 11:20
  • I dont think so. You just cant show 2 activites at the same time. That's called multitasking and Android doesnt support that. – Tooroop Oct 30 '13 at 13:12
0

Its propably too late ... but for others with the same problem:

check out how-to-draw-on-top-of-other-applications

and maybe also this if your app need to be on top on fullscreen apps

Community
  • 1
  • 1
Stephan R.
  • 11
  • 2
  • Weclome to SO! Link only posts are considered lower quality, can you provide more details from the sites you linked to rather than linking directly? – ewitkows Aug 18 '16 at 13:02