Android Bring Back to Original State - android

This might be a noob question.
Actually I am trying to toggle the Activity Windows using a click.
With one click , my Activity goes FullScreen and the Next time I click , It should come back to Non-FullScreen State.
I made if Full Screen using:
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
but now I cannot return back to the NonFullScreen State.
How can I do it?
Thanks in Advance :)

To enable full screen:
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
To go back to non-fullscreen:
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

Related

When I click back arrow made on title bar instead of going to previous panel it goes out of the application?

.When I click "back arrow"on the titlebar it has to move back from TeacherAdminPanel to StudentAdminPanel but it goes out of system, I have tried a lot but cannot solve this, as myself introduce as a beginner for android.Please help me!
<activity
android:name=".teacher_admin_panel"
android:label="TeacherAdminPanel"
android:parentActivityName=".Student_AdminPanel"/>
//This is the code for Androidmanifest.xml
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
//This is the code for backarrow in the TeacherAdminPanel
When you shift activity, do you finish the activity you are going from? If you finish the activity you remove it from the activity backstack, hence you have nothing to go back to, so the app will close.
https://developer.android.com/guide/components/activities/tasks-and-back-stack

do FullScreen Activity in android when press button

I have an activity that I want when press an option in menu to make this activity as full screen and when press other option in menu back to normal activity.
how to do this in code considering that I stopped the landScape layout
Thanks in advance.
I have an activity that I want when press an option in menu to make
this activity as full screen and when press other option in menu back
to normal activity. how to do this in code considering that I stopped
the landScape layout
I think your goal is not possible because it can be done only and also it has to be called in onCreate() method like this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
or via XML
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Try using the window class from the Android API -
requestWindowFeature(Window.FEATURE_NO_TITLE)
You could probably do it just by calling recreate() (level 11, if I recall) on your Activity. Whether that's a good idea, is another thing altogether.

Android Navigation bar appearing when in full screen

In my application, I have set it up in the XML so it is in full screen using
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Now this works fine when the app opens, however if while using the app, I use the home button to back out of the app, and then open it again, when it opens, a black navigation bar will appear for a second or two before disappearing. This does not occur if I exit the app using the back button, just the home button.
Does anyone know why this happens? I have tried doing it from code instead using
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
However, what this does is removes the title bar, but the black bar is there at the top, just nothing is in it.
I.e. this bar
I tried combining the code, by putting the full screen line of code in the XML and also adding the code I showed above into the app, but same thing happens. If I back out of the app with home button and enter it again, that black bar will appear for two seconds temporarily pushing the app and its contents down before righting itself again.
How do I go about fixing this? I have been trying loads of different solutions, but nothing seems to work.
Thanks in advance
Seems to a bug with Android OS. Only way to fix it is go to device, settings animation, and disable animations.
try to remove animation by setting->brightness->animation
set no animation there

Remove state maintenance of screens Android?

I am very new developer for Android application so please ignore if there is some technical mistakes in my question.
I have five screen (Home, SR-1, SR-2,SR-3,SR-4 ) in my Android application and I can switch any screen at give time.
When we are pressing device back button it will take we to the previous screen where I was lastly.
But whenever I am pressing Home it will take me to landing screen If in this state I am pressing device back button I will take me to previous view but I want to remove this state maintenance.
(i.e. : When I am coming to Home and I pressed back button It will exit from my application)
Thank you
for each activity: you can add in AndroidManifest.xml
<activity android:name="nameofActivity"
android:noHistory="true"></activity>
From android pressing back button should exit the app :
Immediately after you start a new activity, using startActivity, make sure you call finish() so that the current activity is not stacked behind the new one.

Completely close/reset my Android app

I've made an Android app, and in its first view you can select a date from a calendar. Everything works fine, but if i push the arrow button on my phone the app seems to close, and i get back to the home screen of my phone.
However if I restart the app by clicking its icon i can see the splash screen, and after this the first view... where the date i selected b4 closing the app is still selected!
Is there a way to completely clear all the variable of my app?
Thanks
Look at the activity livecycle: http://developer.android.com/reference/android/app/Activity.html
At onResume() you could clear the variables!
Your activity isn't destroyed right away when you hit the back button. If you want all data to be destroyed when someone leaves the app then clear the data out in the onPause() method.

Categories

Resources