2

I am creating an app which is basically an activity that automatically runs starts a service. I have defined the activity as transparent, just like the post here suggests :

How do I create a transparent Activity on Android?

however when the app starts, the transparent activity makes the phone "locked". I can't press anything . I know that it's because I am currently focused on a transparent activity, but I thought transparent also means that everything underneath it is clickable.

how do I fix that?

my manifest :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.imagine.imagineinputmanager">

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

    <application


        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:name=".MainActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

        </activity>

        <receiver android:name=".BootReceiver">

            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>

        </receiver>

        <service android:name=".InputService">
            <intent-filter>
                <action android:name=".InputBinder"/>
            </intent-filter>
        </service>

    </application>

</manifest>
Community
  • 1
  • 1
yanish
  • 257
  • 2
  • 15
  • Your UI thread is blocked because of some possible parallel work – Haroon Apr 27 '16 at 07:26
  • What's the point of this transparent activity? If it's only to start the service you can simply finish the activity after starting the service. But I don't really see why you'd need an activity just for that... Seems to me you chose a bad solution to begin with (Though I don't know what is it that you're actually trying to solve). – nitzanj Apr 27 '16 at 07:51
  • @nitzanj starting a service is just one of the things it will do. I also want it to listen to key events – yanish Apr 27 '16 at 07:55
  • Transparent only means you can see through it, e.g. the window for your activity has no background. – Karakuri Apr 27 '16 at 07:57
  • @Karakuri so it necessarily means the UI is blocked? – yanish Apr 27 '16 at 07:58
  • @Haroon is incorrect. Nothing you've shown us so far suggests the UI thread is blocked. You just have a transparent activity with no other UI elements, and it is receiving all the touch events because (shockingly) that's what they're supposed to do. – Karakuri Apr 27 '16 at 07:59
  • @Karakuri ok so what if I don't want it to receive the touch events? – yanish Apr 27 '16 at 08:02
  • As others have suggested, perhaps you shouldn't be using an activity at all. – Karakuri Apr 27 '16 at 08:02
  • what are the possible reasons that makes the phone locked ? while running application , he must be doing some parallel work on UI thread that's why i told him like that . if irrelevant sorry – Haroon Apr 27 '16 at 08:13

1 Answers1

0

i'm so late but i got a solution through this link

In your MainActivity.java just add the following code

 getWindow().addFlags(
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
Hussnain Hashmi
  • 203
  • 2
  • 9