Android drawing over other apps

Android-приложение поверх других приложений

В 2013-году Facebook выпустил функцию Chat Heads для своего мессенджера, который позволяет вести переписку, не открывая сам мессенджер путем нажатия на маленькое круглое окошко, которое всегда висит на дисплее даже поверх других приложений:

Facebook одним из первых продемонстрировал реализацию «Drawing over other apps». Данную возможность разработчики сейчас используют в различных типах приложений — от боковых смарт-меню до записи экрана. В этой статье, хочу продеменстрировать процесс написания приложения-поверх-других-приложений на примере «анти-шпионской» программы Khameleon.

Для начала обозначу цели приложения, который будет реализован как пример приложения-поверх-других-приложений. Допустим нужно, чтобы рядом стоящие люди не могли с легкостью видеть контент моего смарфтона, пока я им пользуюсь. То есть необходима возможность:

  1. Скрывать часть дисплея, чтобы видеть только необходимую область
  2. Вместо скрытой области, показывать любой желаемый контент (например заданную веб страницу)

Примерно это может выглядеть так:

С функционалом приложения определились — теперь приступим к самому туториалу. Для написания приложения-поверх-других-приложений есть две самых главных составляющих:

  • Service, через который ведется основной контроль и логика приложения
  • Layout, который собственно и является GUI

Перед тем как реализовывать эти два компонента, необходимо получить разрешение для приложения-поверх-других-приложений. Для этого в AndroidManifest.xml необходимо добавить:

А для API > 23, т.е. Android M, нужно запросить разрешение в главном Activity:

После того как разрешение получено, укажем Layout, который нужно отобразвить на экране (многие элементы убраны для демонстрации):

В корневой RelativeLayout (по вашему усмотрению) можно поместить любые View’шки как обычно. View с нам нужен для того, чтобы показать как динамично менять размеры Layout. То есть через эту View’шку можно будет расстягивать и сжимать корневой RelativeLayout.

Как только у нас есть минимальный Layout, необходимо реализовать самый обычный Service. Единственная особенность сервиса в добавлении ранее созданного Layout:

На данном этапе наш Layout успешно отображается поверх других приложении. Теперь рассмотрим как можно динамично менять размеры нашего Layout:

Если потянуть за край Layout вверх или вниз, его высота соответственно сжимается и расширяется.

Мы рассмотрели минимальные необходимые шаги для написания приложения-поверх-других-приложений. Полный код для приложенения Khameleon, продемонстрированный выше, можно найти здесь.

Источник

How to Draw Over Other Apps in Android?

Sometimes we require our app to show some content on the main screen irrespective of the app running in the foreground, this process is known as drawing over other apps. There are many apps that use this functionality to provide maximum features with minimum screen coverage. This also enables the user to do multitasking. For example, the chat bubble of Facebook Messenger, Mobile Over Usage notice of YourHour App, Voice Command of Google, and many more. We can create similar functionality using the WindowManager interface provided by Android SDK.

Android WindowManager

The Android WindowManager is a system service that controls which windows are displayed and how they are arranged on the screen. When you launch or close an app or rotate the screen, it automatically executes window transitions and animations, among other things.

Читайте также:  Android настройка чувствительности это

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.

Every activity has its own Window that displays its content on the screen. When you execute setContentView on an activity, it adds the view to the default window of the activity. Because the default window fills the screen and hides any other activities, the WindowManager will show whatever window is on top. So, in most cases, you don’t need to bother about windows; simply build activity, and Android will take care of the rest. In order to manipulate the Window, we need to interact with the window manager. Now in order to display over other apps, we need to create some kind of service, because the activity will close when some other app comes into the foreground.

What we are going to build in this article?

A sample video is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Java language.

Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.

Источник

What does mean by Draw Over other apps or Display over apps on Android- Is it safe?

Many mobile apps require access to “draw over other apps permission” or sometimes written as Display over apps to function.

But what happens if this is allowed? Is it safe? Should you allow it? Let’s find out the truth. While in the meantime, see our top picks for android tablets.

If you’re thinking of what draw-over apps do? Here’s the example.

Table of Contents

Draw over Others apps means:

The permission allows an application to see every kind of activity performed on other applications.

Simply put, if enabled- the app can display top over other apps you may interfere, and can see what you type, see whatever you’re doing, and can also record a video.

Therefore, it’s so risky and should only be granted if the app is completely trusted.

But on the other hand, many apps wouldn’t do a job properly without this android permission, and will pop up an error saying “screen overlay detective.” Because of their structure and work-function.

For example, streaming apps precisely need to be granted draw-over access.

When streaming games like Pubg, Fortnite, Minecraft. they can record the screen of other apps and make it live.

How to enable Draw over apps for an App?

  • To enable this permission for an app is so simple. Android versions 5, 7, 8, automatically enable this, if the app is downloaded from the Google Play store.
  • For Android versions 9, and 10, ask for manually enable draw-over apps permission for an app.
  • To do this, Go to the settings> App settings> On the top-right tap on the three dots and Choose the Special access. Tap “Draw over other apps” and toggle the app in the list.
  • On phones running Android, Vivo, and Oppo, the permission is named as Floating Window App Permission, since enabling it permits apps the same access as drawing over apps.
Читайте также:  Диагностика авто андроид ваз

Is it safe to allow an app to “Draw over apps”?

To say anything specifically certain, the first thing to mind- there are rumors of android being a place for hijackers.

For the fact, any app with lots of permissions such as photos, camera, storage, network, microphone, will have access to all of them and can mess up if intended.

Regarding safety regarding apps that require draw-over app permission.

  • The better answer will be as long as the app itself is trusted among the users, by means the apps should not have been a part of any awful news.
  • Always make sure by first by reading reviews to see whether people are complaining about the app or found it useful.
  • You’re not alone thinking of how dangerous this could be, mostly banking apps don’t allow this permission for security purposes.
  • Or at least they don’t show passwords and other crucial details when they detect third-party apps running on the top and seeing the activities.

If nothing wrong is found in this research, you can give that app permission to draw over other apps. The trusted apps list can be loaded with apps such as Facebook, messenger app, Superpower cleaners, A-z screen recorder.

Which kind of apps require this permission?

Different apps require different kinds of permissions to function properly.

With this being said, apps that plug away as an overlay such as the messenger app turn into an icon upon a msg received.

So that you will get the text flat-out no matter you’re navigating on your smartphone, either watching a Netflix movie or browsing something interested on the Instagram app.

There to deliver the text-msg to you real-quick, the messenger app needs to have to draw over apps.

These kind of apps ask for drawover other apps permission.

  • Cleaning apps
  • Screen recorders,
  • Launchers.
  • Facebook messenger.
  • Spy cams.
  • Video calling apps,

Will always ask you to give them this permission.

Источник

Draw over other apps on Android

‘Draw Over Other Apps’ or ‘Display Over Other apps’ is a special permission on Android device which allows one app to appear on the top of other apps. For example, some screen recorders may require this permission in order to record any other apps on your phone or tablet. On the other side, some apps wouldn’t run when an app was running on top of them and generate a “Screen Overlay Detected” error asking you to turn off the screen overlay, draw over or display over other apps.

Android users can follow below steps to enable or disable draw over other apps permissions on an Android device.

Open Settings. Scroll down to Apps. Tap it to open the list of all your apps n the device. Tap the More menu(three dots) at the top right corner and choose Configure apps from the drop-down list.

Select Draw Over Other Apps. Sometimes this option may be in a sub-menu. For example, I have to open the Special access in the Advanced section, then access the Draw over other apps on my LG smartphone.

Now the list of all apps with/without ‘draw over other apps’ permissions will appear. You can tap an app, then choose enable or disable the ‘draw over other apps’ permission on your Android phone.

Источник

How To : Android 8.1 Oreo Lets You Hide ‘Running in the Background’ & ‘Drawing Over Other Apps’ Notifications

One of Android 8.0’s central themes was battery improvements. Google implemented background restrictions and a few other under-the-hood changes, but the biggest battery-saving measure was almost user-hostile: A static notification that tells you when any of your apps are running in the background.

Читайте также:  Форматирование microsd карты для android

This notification couldn’t be dismissed, so it’s likely that Google did this with the intent of annoying users. You see, if an app hasn’t been updated to target Oreo’s new API, those background restrictions won’t really work. And since Google can’t force developers to make their apps more battery-friendly, they did the next-best thing: Annoy users by calling out poorly coded apps with a non-removable notification.

For security purposes, they also added a static notification when you have any apps that draw over other apps — for instance, popup apps and those with floating bubble interfaces like Facebook Chatheads. These could theoretically trick you into pressing a button that you didn’t meant to press, so something had to be done.

Thankfully, the new Android 8.1 update that just started rolling out has a compromise for both of these issues. With a tiny bit of work, you can now hide both the «Apps running in the background» (now called «Apps using battery») as well as the «Drawing over other apps» notifications.

Hiding the ‘Drawing Over Other Apps’ Notification

When an app is drawing over top of other apps on Android 8.1, you’ll still see that same pesky «Drawing over other apps» notification. You still can’t swipe it away, but you can get rid of it altogether.

Just long-press the offending notification, then toggle the switch to the off position, and you’ll never see this notification for that particular app again. It will still appear for other apps, but you can give those the same treatment.

Hiding the ‘Apps Using Battery’ Notification

As for the «Apps running in the background» notification, it’s still there in 8.1, but it now says «Apps using battery.» Again, you can’t just swipe it away, but you can long-press it, then turn the toggle switch off to hide the notification for that particular app (just like with the «Drawing over other apps» notification above).

But there’s an even better way to handle this one that makes it to where you’ll never see this type of notification again. To start, just head to Settings –> Apps & notifications, then tap «See all apps.» From there, press the three-dot menu button in the top-right corner and select «Show system.»

Next, scroll down a bit and select the «Android System» app. From there, tap the «App notifications» entry on the subsequent screen. Finally, scroll down and find the «Apps using battery» setting, then simply disable the switch next to it. From now on, you won’t see a notification when apps are running in the background!

These are just some of the many changes in the new Android 8.1 update, which will roll out to all eligible Pixel and Nexus devices as an official update in December. But if you’d like to try Android 8.1 right now, or if you just want to know more about the changes, make sure to hit up our full article on the topic below.

Keep Your Connection Secure Without a Monthly Bill. Get a lifetime subscription to VPN Unlimited for all your devices with a one-time purchase from the new Gadget Hacks Shop, and watch Hulu or Netflix without regional restrictions, increase security when browsing on public networks, and more.

Источник

Оцените статью