0

I'm making an Android translating application working in the background, reading text shown on the screen, translating and showing translated sentences on the bottom of the screen. The sentences(and maybe some images) must be clicked through.

The thing I'm concerned is that whether I can make a view with messages or images over a running application. Does Android support this kind of function? I'm developing with Android studio. Thanks in advance.

Yeongchan Jeon
  • 499
  • 3
  • 18
  • Check this ans http://stackoverflow.com/a/34409531/1140237 . this guy given answer with how to show view from background running service. `HBFloatingHead` is used to show view from service – user1140237 Jan 28 '16 at 07:58

3 Answers3

2

Yes, it is possible, but you need to use a permission TYPE_SYSTEM_ALERT for this, and starting from Android 6, you also need to request this permission at runtime.

Here's a tiny sample of how to do it:

https://github.com/mollyIV/ChatHeads

and a video:

https://www.youtube.com/watch?v=CCLs1pEukxo

Note that you always need to check if the permission is given on Android 6 and above, especially if your targetSdk is 22 or below. The reason is that the app can crash if the permission is revoked : https://code.google.com/p/android/issues/detail?id=196597

Also, in order to capture what the screen shows, this is also possible: How to record screen and take screenshots, using Android API?

And, if you wish to get it as text, you can do what Google-now-on-tap does: http://developer.android.com/training/articles/assistant.html#implementing_your_own_assistant

Community
  • 1
  • 1
android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • TYPE_SYSTEM_ALERT is deprecated from API 26. Use [TYPE_APPLICATION_OVERLAY](https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_SYSTEM_ALERT) instead – Adrian Grygutis Feb 06 '18 at 13:37
1

Answer if android support that is NO. But, there are application which do this. Exmaple facebook messenger do this when new message income. How facebook messenger do this. I think this is done be WindowManager.

mWindowManager = (WindowManager)mContext.getSystemService("window");
mWindowManager.addView(v, mWindowParams);
mariopce
  • 1,116
  • 9
  • 17
0

you can use DRAW OVER OTHER APPS to open a view over a running application.


for that you have to use android.permission.SYSTEM_ALERT_WINDOW permission in android manifest file. if your support android 6.0 then you have to ask use to allow permission. how to use runtime-permission android 6.0.


best stack answer

here is some of sample code available on github.

DesignOverlay-Android

Community
  • 1
  • 1
Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177