How do I detect touch input on the Android when application is running in the background





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I want to detect if a particular gesture was made in some other screen (Not when the app's UI is open).



I have seen it in some phones, you make a 'C' kind of gesture and the camera will open. Is there something like this in Android Studio?










share|improve this question

























  • You are asking like " If i touch Whatsapp chat how I can detect it in Gmail App"

    – Zaid Mirza
    Nov 25 '18 at 5:05











  • Something similar. I want to use one gesture anywhere in my phone and call an Intent of my app. So that i can perform action according to the gesture. I know this will be major security concern but I am trying to make this app for myself and to be used in my own phone, So I don't mind giving the permission (if needed).

    –  Rana
    Nov 25 '18 at 7:44


















0















I want to detect if a particular gesture was made in some other screen (Not when the app's UI is open).



I have seen it in some phones, you make a 'C' kind of gesture and the camera will open. Is there something like this in Android Studio?










share|improve this question

























  • You are asking like " If i touch Whatsapp chat how I can detect it in Gmail App"

    – Zaid Mirza
    Nov 25 '18 at 5:05











  • Something similar. I want to use one gesture anywhere in my phone and call an Intent of my app. So that i can perform action according to the gesture. I know this will be major security concern but I am trying to make this app for myself and to be used in my own phone, So I don't mind giving the permission (if needed).

    –  Rana
    Nov 25 '18 at 7:44














0












0








0








I want to detect if a particular gesture was made in some other screen (Not when the app's UI is open).



I have seen it in some phones, you make a 'C' kind of gesture and the camera will open. Is there something like this in Android Studio?










share|improve this question
















I want to detect if a particular gesture was made in some other screen (Not when the app's UI is open).



I have seen it in some phones, you make a 'C' kind of gesture and the camera will open. Is there something like this in Android Studio?







android android-studio gesture






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 4:58









jake

39519




39519










asked Nov 25 '18 at 4:53









Rana Rana

13




13













  • You are asking like " If i touch Whatsapp chat how I can detect it in Gmail App"

    – Zaid Mirza
    Nov 25 '18 at 5:05











  • Something similar. I want to use one gesture anywhere in my phone and call an Intent of my app. So that i can perform action according to the gesture. I know this will be major security concern but I am trying to make this app for myself and to be used in my own phone, So I don't mind giving the permission (if needed).

    –  Rana
    Nov 25 '18 at 7:44



















  • You are asking like " If i touch Whatsapp chat how I can detect it in Gmail App"

    – Zaid Mirza
    Nov 25 '18 at 5:05











  • Something similar. I want to use one gesture anywhere in my phone and call an Intent of my app. So that i can perform action according to the gesture. I know this will be major security concern but I am trying to make this app for myself and to be used in my own phone, So I don't mind giving the permission (if needed).

    –  Rana
    Nov 25 '18 at 7:44

















You are asking like " If i touch Whatsapp chat how I can detect it in Gmail App"

– Zaid Mirza
Nov 25 '18 at 5:05





You are asking like " If i touch Whatsapp chat how I can detect it in Gmail App"

– Zaid Mirza
Nov 25 '18 at 5:05













Something similar. I want to use one gesture anywhere in my phone and call an Intent of my app. So that i can perform action according to the gesture. I know this will be major security concern but I am trying to make this app for myself and to be used in my own phone, So I don't mind giving the permission (if needed).

–  Rana
Nov 25 '18 at 7:44





Something similar. I want to use one gesture anywhere in my phone and call an Intent of my app. So that i can perform action according to the gesture. I know this will be major security concern but I am trying to make this app for myself and to be used in my own phone, So I don't mind giving the permission (if needed).

–  Rana
Nov 25 '18 at 7:44












1 Answer
1






active

oldest

votes


















0














You can do that using Service that is running on background.



As you know, there is some applications which are using this skill such as Facebook messenger.



You can handle touch event in setOnTouchListener callback implementation of FloatingService.kt.



Please refer my source code.





[FloatingService.kt]



package com.antasis9.android.playground

import android.app.Service
import android.content.Context
import android.content.Intent
import android.graphics.PixelFormat
import android.os.IBinder
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.Button

class FloatingService : Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Log.d("FloatingService", "FloatingService.onStartCommand()");

val layout = LayoutInflater.from(this).inflate(R.layout.activity_floating, null)
layout.setOnTouchListener { v, event ->

// HANDLE TOUCH EVENT HERE!

Log.d("FloatingService", "v: $v, event: $event")
false
}

val layoutParams = WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT
)

(getSystemService(Context.WINDOW_SERVICE) as WindowManager).addView(layout, layoutParams)

return super.onStartCommand(intent, flags, startId)
}

override fun onBind(intent: Intent): IBinder? {
return null
}
}




[activity_floating.xml]



<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
</android.support.constraint.ConstraintLayout>




[MainActivity.java]



I used activity to start FloatingService but you can start this service with other ways.



package com.antasis9.android.playground;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), FloatingService.class);
startService(intent);
}
});

findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), FloatingService.class);
stopService(intent);
}
});
}
}




[AndroidManifest.xml]



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.antasis9.android.playground">

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<service
android:name=".FloatingService"
android:enabled="true"
android:exported="false"></service>
</application>
</manifest>




[This is last step]



You should turn on 'display over other apps' option.



You can find this option 'Settings' -> 'Apps' -> Select {your app name}



Turn on 'display over other apps' option






share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464753%2fhow-do-i-detect-touch-input-on-the-android-when-application-is-running-in-the-ba%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can do that using Service that is running on background.



    As you know, there is some applications which are using this skill such as Facebook messenger.



    You can handle touch event in setOnTouchListener callback implementation of FloatingService.kt.



    Please refer my source code.





    [FloatingService.kt]



    package com.antasis9.android.playground

    import android.app.Service
    import android.content.Context
    import android.content.Intent
    import android.graphics.PixelFormat
    import android.os.IBinder
    import android.util.Log
    import android.view.LayoutInflater
    import android.view.ViewGroup
    import android.view.WindowManager
    import android.widget.Button

    class FloatingService : Service() {
    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
    Log.d("FloatingService", "FloatingService.onStartCommand()");

    val layout = LayoutInflater.from(this).inflate(R.layout.activity_floating, null)
    layout.setOnTouchListener { v, event ->

    // HANDLE TOUCH EVENT HERE!

    Log.d("FloatingService", "v: $v, event: $event")
    false
    }

    val layoutParams = WindowManager.LayoutParams(
    WindowManager.LayoutParams.MATCH_PARENT,
    WindowManager.LayoutParams.MATCH_PARENT,
    WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
    PixelFormat.TRANSLUCENT
    )

    (getSystemService(Context.WINDOW_SERVICE) as WindowManager).addView(layout, layoutParams)

    return super.onStartCommand(intent, flags, startId)
    }

    override fun onBind(intent: Intent): IBinder? {
    return null
    }
    }




    [activity_floating.xml]



    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent">
    </android.support.constraint.ConstraintLayout>




    [MainActivity.java]



    I used activity to start FloatingService but you can start this service with other ways.



    package com.antasis9.android.playground;

    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;

    public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent intent = new Intent(getApplicationContext(), FloatingService.class);
    startService(intent);
    }
    });

    findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent intent = new Intent(getApplicationContext(), FloatingService.class);
    stopService(intent);
    }
    });
    }
    }




    [AndroidManifest.xml]



    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.antasis9.android.playground">

    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

    <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>

    <service
    android:name=".FloatingService"
    android:enabled="true"
    android:exported="false"></service>
    </application>
    </manifest>




    [This is last step]



    You should turn on 'display over other apps' option.



    You can find this option 'Settings' -> 'Apps' -> Select {your app name}



    Turn on 'display over other apps' option






    share|improve this answer






























      0














      You can do that using Service that is running on background.



      As you know, there is some applications which are using this skill such as Facebook messenger.



      You can handle touch event in setOnTouchListener callback implementation of FloatingService.kt.



      Please refer my source code.





      [FloatingService.kt]



      package com.antasis9.android.playground

      import android.app.Service
      import android.content.Context
      import android.content.Intent
      import android.graphics.PixelFormat
      import android.os.IBinder
      import android.util.Log
      import android.view.LayoutInflater
      import android.view.ViewGroup
      import android.view.WindowManager
      import android.widget.Button

      class FloatingService : Service() {
      override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
      Log.d("FloatingService", "FloatingService.onStartCommand()");

      val layout = LayoutInflater.from(this).inflate(R.layout.activity_floating, null)
      layout.setOnTouchListener { v, event ->

      // HANDLE TOUCH EVENT HERE!

      Log.d("FloatingService", "v: $v, event: $event")
      false
      }

      val layoutParams = WindowManager.LayoutParams(
      WindowManager.LayoutParams.MATCH_PARENT,
      WindowManager.LayoutParams.MATCH_PARENT,
      WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
      WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
      PixelFormat.TRANSLUCENT
      )

      (getSystemService(Context.WINDOW_SERVICE) as WindowManager).addView(layout, layoutParams)

      return super.onStartCommand(intent, flags, startId)
      }

      override fun onBind(intent: Intent): IBinder? {
      return null
      }
      }




      [activity_floating.xml]



      <?xml version="1.0" encoding="utf-8"?>
      <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@android:color/transparent">
      </android.support.constraint.ConstraintLayout>




      [MainActivity.java]



      I used activity to start FloatingService but you can start this service with other ways.



      package com.antasis9.android.playground;

      import android.content.Intent;
      import android.support.v7.app.AppCompatActivity;
      import android.os.Bundle;
      import android.view.View;

      public class MainActivity extends AppCompatActivity {

      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      Intent intent = new Intent(getApplicationContext(), FloatingService.class);
      startService(intent);
      }
      });

      findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      Intent intent = new Intent(getApplicationContext(), FloatingService.class);
      stopService(intent);
      }
      });
      }
      }




      [AndroidManifest.xml]



      <?xml version="1.0" encoding="utf-8"?>
      <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.antasis9.android.playground">

      <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

      <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
      <intent-filter>
      <action android:name="android.intent.action.MAIN" />

      <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      </activity>

      <service
      android:name=".FloatingService"
      android:enabled="true"
      android:exported="false"></service>
      </application>
      </manifest>




      [This is last step]



      You should turn on 'display over other apps' option.



      You can find this option 'Settings' -> 'Apps' -> Select {your app name}



      Turn on 'display over other apps' option






      share|improve this answer




























        0












        0








        0







        You can do that using Service that is running on background.



        As you know, there is some applications which are using this skill such as Facebook messenger.



        You can handle touch event in setOnTouchListener callback implementation of FloatingService.kt.



        Please refer my source code.





        [FloatingService.kt]



        package com.antasis9.android.playground

        import android.app.Service
        import android.content.Context
        import android.content.Intent
        import android.graphics.PixelFormat
        import android.os.IBinder
        import android.util.Log
        import android.view.LayoutInflater
        import android.view.ViewGroup
        import android.view.WindowManager
        import android.widget.Button

        class FloatingService : Service() {
        override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        Log.d("FloatingService", "FloatingService.onStartCommand()");

        val layout = LayoutInflater.from(this).inflate(R.layout.activity_floating, null)
        layout.setOnTouchListener { v, event ->

        // HANDLE TOUCH EVENT HERE!

        Log.d("FloatingService", "v: $v, event: $event")
        false
        }

        val layoutParams = WindowManager.LayoutParams(
        WindowManager.LayoutParams.MATCH_PARENT,
        WindowManager.LayoutParams.MATCH_PARENT,
        WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
        PixelFormat.TRANSLUCENT
        )

        (getSystemService(Context.WINDOW_SERVICE) as WindowManager).addView(layout, layoutParams)

        return super.onStartCommand(intent, flags, startId)
        }

        override fun onBind(intent: Intent): IBinder? {
        return null
        }
        }




        [activity_floating.xml]



        <?xml version="1.0" encoding="utf-8"?>
        <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent">
        </android.support.constraint.ConstraintLayout>




        [MainActivity.java]



        I used activity to start FloatingService but you can start this service with other ways.



        package com.antasis9.android.playground;

        import android.content.Intent;
        import android.support.v7.app.AppCompatActivity;
        import android.os.Bundle;
        import android.view.View;

        public class MainActivity extends AppCompatActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        Intent intent = new Intent(getApplicationContext(), FloatingService.class);
        startService(intent);
        }
        });

        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        Intent intent = new Intent(getApplicationContext(), FloatingService.class);
        stopService(intent);
        }
        });
        }
        }




        [AndroidManifest.xml]



        <?xml version="1.0" encoding="utf-8"?>
        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.antasis9.android.playground">

        <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

        <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
        <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        </activity>

        <service
        android:name=".FloatingService"
        android:enabled="true"
        android:exported="false"></service>
        </application>
        </manifest>




        [This is last step]



        You should turn on 'display over other apps' option.



        You can find this option 'Settings' -> 'Apps' -> Select {your app name}



        Turn on 'display over other apps' option






        share|improve this answer















        You can do that using Service that is running on background.



        As you know, there is some applications which are using this skill such as Facebook messenger.



        You can handle touch event in setOnTouchListener callback implementation of FloatingService.kt.



        Please refer my source code.





        [FloatingService.kt]



        package com.antasis9.android.playground

        import android.app.Service
        import android.content.Context
        import android.content.Intent
        import android.graphics.PixelFormat
        import android.os.IBinder
        import android.util.Log
        import android.view.LayoutInflater
        import android.view.ViewGroup
        import android.view.WindowManager
        import android.widget.Button

        class FloatingService : Service() {
        override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        Log.d("FloatingService", "FloatingService.onStartCommand()");

        val layout = LayoutInflater.from(this).inflate(R.layout.activity_floating, null)
        layout.setOnTouchListener { v, event ->

        // HANDLE TOUCH EVENT HERE!

        Log.d("FloatingService", "v: $v, event: $event")
        false
        }

        val layoutParams = WindowManager.LayoutParams(
        WindowManager.LayoutParams.MATCH_PARENT,
        WindowManager.LayoutParams.MATCH_PARENT,
        WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
        PixelFormat.TRANSLUCENT
        )

        (getSystemService(Context.WINDOW_SERVICE) as WindowManager).addView(layout, layoutParams)

        return super.onStartCommand(intent, flags, startId)
        }

        override fun onBind(intent: Intent): IBinder? {
        return null
        }
        }




        [activity_floating.xml]



        <?xml version="1.0" encoding="utf-8"?>
        <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent">
        </android.support.constraint.ConstraintLayout>




        [MainActivity.java]



        I used activity to start FloatingService but you can start this service with other ways.



        package com.antasis9.android.playground;

        import android.content.Intent;
        import android.support.v7.app.AppCompatActivity;
        import android.os.Bundle;
        import android.view.View;

        public class MainActivity extends AppCompatActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        Intent intent = new Intent(getApplicationContext(), FloatingService.class);
        startService(intent);
        }
        });

        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        Intent intent = new Intent(getApplicationContext(), FloatingService.class);
        stopService(intent);
        }
        });
        }
        }




        [AndroidManifest.xml]



        <?xml version="1.0" encoding="utf-8"?>
        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.antasis9.android.playground">

        <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

        <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
        <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        </activity>

        <service
        android:name=".FloatingService"
        android:enabled="true"
        android:exported="false"></service>
        </application>
        </manifest>




        [This is last step]



        You should turn on 'display over other apps' option.



        You can find this option 'Settings' -> 'Apps' -> Select {your app name}



        Turn on 'display over other apps' option







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 25 '18 at 12:32

























        answered Nov 25 '18 at 12:27









        Seungmin HaSeungmin Ha

        12115




        12115
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464753%2fhow-do-i-detect-touch-input-on-the-android-when-application-is-running-in-the-ba%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Xamarin.form Move up view when keyboard appear

            JBPM : POST request for execute process go wrong