do FullScreen Activity in android when press button - android

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.

Related

Show splash screen when application enters background android

How can I show android splash screen when the application goes to the back ground?
The issue is that I need to hide my application main page when the user sends the app to the background, and when s/he double tabs the home button, they will see the splash screen.
We were using the following inside our code :
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE);
.
.
It looks like it is fixing the issue, but this code is preventing the user from taking screenshot on the device if the app is in the foreground.
I'm not sure how to implement what i need like I did in iOS.
thanks.
Now I haven't personally tried this so I'm not sure if it'll work, but you can try overriding the onPause() method. After overriding onPause() add code that sets your splash screen to cover the entire activity. This should put the image as the app preview in the Recents Panel. Then override the onResume() method to remove the image from the activity, giving the user control again.

How to affect the snapshot Android takes from application when going to background

My question is about the Android system taking snapshot of application screen when entering background. I have some secure content in application which I would like to hide in that point, so if user enters background and opens recent apps, I could show always the same content (for example splash screen) for my application instead of the last screen visible before entered to background.
Is this possible at all?
Thanks.
Please do not post answers about FLAG_SECURE, I do not want the screen to be black and also found a bug from it: http://code.google.com/p/android/issues/detail?id=64086
Use FLAG_SECURE .
Usage:
public class FlagSecureTestActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE);
setContentView(R.layout.main);
}
}
That will prevent from a screenshot being taken of that activity. And will show a blank screen for that app in the recent apps list.
Edit:
Other than FLAG_SECURE there doesn't seem any method to prevent a screenshot from being taken. However, I'd suggest this unclean workaround instead. I've not tried this, just an idea:
Override the onPause() and onBackPressed() methods of the Activity. So when the home or back button are pressed, these are called.
Then , inside these, use setContentView() to show another dummy view or a splash screen for that matter. So that this splash view becomes the last shown View.
After point 2, call super.onPause() or super.onBackPressed() , so that the screenshot is taken, of this splash screen. Don't call them before point 2.

How to hide last activity view in android recent list? Using a locker screen implementation

I am using an implementation of locker screen which locks (is displayed on top) the current activity when it is idle for X seconds.
However the view for the locker activity is not displayed in the preview image after clicking the Home and Recent buttons.
How could I force to make my app's view blank or display my locker view in the recent list?
I could set my activity visible to gone, but is there any other solution?
Try FLAG_SECURE:
public class FlagSecureTestActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE);
setContentView(R.layout.main);
}
}
It will automatically display a grey background when Recents button is pressed.
A possible side-effect would be that you cant take the screenshot of the activity you are defining this way.
Try the attribute, android:noHistory="true" for the activity tag in the manifest file.
The recents app gets something like a "screenshot" when the app goes to background, so before go to background you can fill your activity with a black LinearLayout and onResume check if this LinearLayout is showing and hide. Maybe there are better solutions but this may works.

Android Bring Back to Original State

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);

TabActivity Implementing

I am trying to make a tab activity. It works fine . I make
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" in the definition in manifest file. But sometimes it does not take the full screen when launching. My program starts from a splash screen. That is an normal activity. My tab is at the buttom of the screen. So the tabs are go inside the screen.
Does Anyone know about the problem?
Remove .FullScreen and instead use
android:theme="#android:style/Theme.NoTitleBar"
with your activity tags in AndroidManifest.XML, worked out for me
EDIT
in your Activity onCreate method use
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

Categories

Resources