I want to make an activity that when called appears as a small popup on top of any current app (or home screen) kinda like google assistant usually does when called. It is intended to ask for a fingerprint input for 3 seconds or hide if user touches outside its window.
Google assistant is service not any popup activity.
you can do popup activity but, it will only work for when app in foreground like google assistant need background service.
you can use theme
android:theme="#android:style/Theme.Holo.Light.Dialog.MinWidth" for activity make like pop dialog. for this theme require activity instead of appcompatactivity.
if you want exclude from recent use in manifest android:excludeFromRecents="true"
<activity
android:name=".ActivityName"
android:excludeFromRecents="true"
android:label="#string/app_name" />
Related
I have to open activity directly on picture-in-picture mode like WhatsApp playing video in chats.
I tried but it launches activity normally and when I click button and apply the code for entering into picture-in-picture mode only it is working.
I need without clicking any button directly launch the activity on picture-in-picture mode
<activity
android:name=".PiPActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:label="#string/title_activity_pi_p"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:supportsPictureInPicture="true"
android:theme="#style/AppTheme.NoActionBar" />
Starting from MainActivity:
startActivity(new Intent(this, PiPActivity.class).putExtra("videoUrl", model.videoUrl));
As far as I know, an activity can not be opened directly in picture-in-picture (pip) mode. It will be first opened as a normal activity only. However, if you want it to go to pip mode as soon as it is launched, you can call enterPictureInPictureMode(yourParamsToBePassed) inside onCreate() or onStart() or onResume() lifecycle callbacks.
WhatsApp playing video in chats
It does not seem like, WhatsApp uses pip mode to launch the video. It is most probably a custom layout (which looks like a PIP view). This can be proven by the fact that this pip-look-alike-layout is not the topmost view of the screen. If you try moving this pip-look-alike-layout, it will be hidden behind ChatNameBar and TypeMessageBar. Basically, its elevation is lesser than those two. This contradicts the fact that the pip view is shown on top of all the running activities/apps.
I want to display android app in full screen for tablets.
I thought of using view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); to hide navigation but the problem is that I have buttons in my view. If I hide navigation like this, every time user want's to click butto, on first click the menu shows up but the button isn't clicked.
I wouldn't care if the menu shows or not after click but I don't want users to ask to click twice to choose something.
What would be the suggested way to display my app in full screen?
use this code:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Just Edit your Manifest.xml file:
Use this code if you want to display all the Activities in Full Screen Mode:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
...
</application>
Use this code if you want to display some Activities in Full Screen Mode:
<activity
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
...
</activity>
I hope this helps.
You can write this line in Activity on onCreate method :
this.requestWindowFeature((int)Window.FEATURE_NO_TITLE);
SYSTEM_UI_FLAG_HIDE_NAVIGATION will cause those navigation controls to just disappear.There is a limitation: because navigation controls are so important, the least user interaction will cause them to reappear immediately.
How to disable/replace the image we see when an android app is running in background and we long press the "home" button? Due to security issues, I need to disable this image.
Just exclude it from recents from your manifest or launch your activity with FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.
To do it from the manifest, you need to explicitly add android:excludeFromRecents="true" to each <activity> tag.
Let's say I have a basic widget with a button. When i click on this button I would like to display a input dialogue window, still on top of the home screen, where upon entering some value and clicking submit I will see the home screen again.
What I do now is to start an activity with a dialogue which is placed on top of the main activity in my application. Perhaps there is just a simple flag to hide the main activity?
Thankful for any help.
To answer my question, this is what needed to be put in the manifest for my dialog activity.
<activity android:name=".InputDialog"
android:launchMode="singleInstance"
android:theme="#android:style/Theme.Dialog"
android:excludeFromRecents="true">
</activity>
I have an app which has 4 activities in it.Within app, history activities, i.e. Activities from where I navigated should not be destroyed , so I don't call finish() when I am navigating.
But when I press HOME button I want to kill all activities , So that When I come back to the app , Index screen or say first activity is displayed instead of previous paused activity.
Problem here seems to be, how to differentiate between backs within an app to HOME button.
I saw few answers regarding this in other questions. Got more confused.
Is there a way other than intercepting HOME KEY PRESS, because as suggested in other threads,
I should not override HOME key press (as it might have side effects)
Set android:clearTaskOnlaunch="true" on the activity launched from the home screen.
You might also check some of the other attributes you can specify on activity, to tweak it's behavior a bit more.
On main activity add:
android:launchMode="singleTask"
android:clearTaskOnLaunch="true"
On the others add:
android:finishOnTaskLaunch="true"
This way it will kill off any activity when returning to the app after being in background.