1

I am making an app for kids where once you're inside the app you can't exit without password which I am asking for in the menu. Now I want if inside app I press home button in the app it should remain on same activity. I searched a lot but everywhere the solution is adding filters in manifest but those are not working well for me. I want my activity to be removed from launcher when app exits and again ask if starts application.

And for the same app if i press recent app button and one of those is clicked by the kid also the app should be in same activity or if there any way to block the recent app button.

I tried this

<activity
    android:label="@string/app_name"
    android:launchMode="singleInstance"
    android:name=".MyActivity"
    android:screenOrientation="landscape"
    android:excludeFromRecents="true"
    android:taskAffinity=""
    android:stateNotNeeded="true" >
    <intent-filter >
        <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.HOME" />
         <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
blahdiblah
  • 33,069
  • 21
  • 98
  • 152
skygeek
  • 1,548
  • 11
  • 24

3 Answers3

2

I am making an app for kids where once you inside the app can't exit without password which i am asking in menu.

Fortunately, this is not possible, for obvious security reasons.

Now i want if inside app i press home button in the app it should remain on same activity, i searched a lot but everywhere the solution is adding filters in manifest but those are not working well for me.

"not working well for me" is a completely useless explanation of your symptoms. There is a Home sample app in your SDK that demonstrates setting up a home screen.

And for the same app if i press recent app button and one of those is clicked by the kid also the app should be in same activity or if there any way to block the recent app button.

Neither of those are possible.

If you want to make a single-purpose Android device, you will need to do so at the firmware level.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • ware : But there are apps present where our activity can behave like launcher on home pressed while our app running and normal behavior after app exits...i hope you have some idea about that. – skygeek Jun 20 '12 at 15:36
  • @akashgupta: I cannot even understand that, let alone have "some idea about that". – CommonsWare Jun 20 '12 at 15:37
  • I am able to make my home activity to behave like as a launcher but on app exit it is not getting normal behavior... – skygeek Jun 20 '12 at 15:40
1

You can turn your app into a launcher. My launchers would typically look like:

<activity android:name=".MyLauncher">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.HOME"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

When the user selects your launcher as the default, the home key will basically do nothing when you are in your application.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
0

This is working like charm since API 14; tested on emulator 4.4v, 5.0v, 7.0v, 8.0v, 9.0v; Here is the link of guy who solved the question: https://stackoverflow.com/a/55129289/9497126

acakojic
  • 306
  • 2
  • 11