Android - Honeycomb or ICS Go Completely Full Screen - java

Is there a way in ICS or Honeycomb to go completely full screen? I want the system UI completely gone! Currently what I do is:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
getWindow().getDecorView().setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
But this results in the Status Bar being replaced by really dim dots! I want it completely gone! Lets say for example I want to play a video or show a picture that takes up the whole screen. I'm okay with the status bar coming back on user interaction but I need it completely gone when there is no user interaction.
With the code above. I get the following look:
I want the dim dots gone as well and my video / image to be completely full screen.

This is not possible in Honeycomb, but has been added in API v14. Use:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
See the more detailed answers over here (though I would use a Build.Version.SDK_INT check instead of the suggested reflection-based check for support):
Hide ICS back home task switcher buttons

As the previous poster Suggested, that is completely impossible without rooting your device and performing some somewhat dirty process kill operations. The reason for is that new Hardware (like a tablet, for instance) may not have hardware buttons for navigation - and so by hiding those buttons the User would have no means of doing things that they are supposed to be guaranteed to be able to do, like going to the home screen, or accessing device info. Whether or not you might agree with that reasoning, such is the API.

The last information I have is that you can use the black tape to cover it. That's the suggestion given by Chet Haase. Watch this google IO 2011 session Q&A starting at 53minutes

You want SYSTEM_UI_FLAG_HIDE_NAVIGATION . Keep in mind that since the soft navigation buttons are key to device experience this only hides the buttons until there is some user interaction. If you want to permanently hide them then rooting the device (as others have suggested) is the only way to go.
The flag was added as of Ice Cream Sandwich, API 14. Previous to 14 a flag STATUS_BAR_HIDDEN was added in Honeycomb, API 11 that had a similar function. Previous to that the soft navigation buttons didn't exist, so fullscreen modes were handled entirely by Themes (specifically Theme.NoTitleBar.Fullscreen).
Use:
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH )
mBaseLayout.setSystemUiVisibility( View.SYSTEM_UI_FLAG_HIDE_NAVIGATION );
else if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB )
mBaseLayout.setSystemUiVisibility( View.STATUS_BAR_HIDDEN );

Related

Why sometimes my Android App restart without a logic explanation?

I'm developing a scientific app in Android Studio. It works smoothy.
The set of source code files is not small, but, as I don't have practically user interface, there is only one activity and there is no intent.
All initialization code is inside OnCreate. Most of times, my app preserves all data, when he gets out of the foreground.
However, maybe (I cannot find a pattern of this event) he loses all data and restart (shows a white screen for 2 / 3 seconds), even if the cell phone don't enter in lock screen and there are just 2 apps running.
There are situations that I comute for another app (like WhatsApp) and resumes for my app, and my data was gone. The app restart again.
There is no error message, no logcat. Nothing.
Mostly, when I lock the screen and enter again, all my app data is there.
PS: My orientation is locked.
PS 2: I've read all related question and there is no hint for me. Based in one answer, I've tried to put in onCreate the following code.
if (!isTaskRoot() {
&& getIntent().hasCategory(Intent.CATEGORY_LAUNCHER)
&& getIntent().getAction() != null
&& getIntent().getAction().equals(Intent.ACTION_MAIN)) {
finish();
return;
}
No changes for me.
Update:
I've stumbled in solution. it can be read in my own answer. it's related to undesired back button effect for one-activity-app (read here and here ).
For me, as my application has only one activity, back needs to be like a home button: exit the app but preserve all activity data. My app has a real exit button, where the user shows that really wants to do this.
It's my first app that I developing in mobile world and, for extension, Android world
Some problems seems to me like that it is only possible find the solution if one has a hint about its solution. it's a contradiction. One doesn't know but has to know to solve that don't know!
And, in this situation, it's not the case. No hints. Just question marks.
Before, I had not noticed any pattern. People sometimes act so automatically ... However, suddenly the penny dropped.
I've stumbled in solution. Fortunately!
Not in a million years could I suppose that if someone has an activity and presses Back button, (right button in the bottom), you practically quit the application, even if it remains as a running app for the left button in the bottom (app switcher button)
When I've noticed it, I start to research with another focus. And I've discovered two sources: Disable back button in android and Android - Simulate Home click
So the solution is simply to make the Back button act like the Home button (middle button in the bottom). Return to the home screen without losing application data.
And this is done simply by putting in the onCreate, for my only activity, the following code.
override fun onBackPressed() {
val i = Intent(Intent.ACTION_MAIN)
i.addCategory(Intent.CATEGORY_HOME)
startActivity(i)
}

Braintree Drop-in Payment UI Customization

I'm trying to use #braintree Drop-in Payment UI in iOS. If someone disables some buttons e.g for Apple Pay, Vemmo or credit card, the space for these buttons still exists as an empty space in the action sheet. Is there any way to eliminate this space?
Additionally, when you make a choice sometimes there is a delay in the response. So the user isn't sure if the button is pressed. Is there a way to avoid pressing the button twice or dismiss the action sheet once a button is pressed?
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
Our action sheet is set to a fixed height regardless of payment methods. You can fork our iOS Drop-in repository to change the height, however, I would recommend referencing Apple's Human Interface Guidelines to ensure adapting this would meet their standards.
Testing my own iOS integration, there is not a delay on the button press. Please reach out to our support team for more specifics around the delays you are seeing.

Mopub banner ads - better control of loading/unloading

I want to have fine control over a MoPub banner ad which appears over the top of my game app screen at specific times and not at others. My code currently looks like this (simplified):
LinearLayout linearlayout_for_banner = new LinearLayout (this);
mAdView = new MoPubView(this);
linearlayout_for_banner.addView(mAdView);
The linearlayout_for_banner is transparent, so when there is no advert, the user can see all of the game-play screen underneath. Then at a certain precise point I wish an ad to appear. At the moment, the only function I know to call is mAdView.loadAd() which as far as I know begins a process of going to the internet to seek an ad, then if it finds one it will be drawn on the screen. This is very unsatisfactory, because there is often a delay before it appears. So what I would like are functions like scoop_an_advert_but_dont_show_it_yet() and now_show_that_ad_you_scooped_earlier(). Do they exist? Mopub's documentation seems rather inadequate on this.
Try browsing their github wiki: https://github.com/mopub/mopub-client/wiki/CustomEventsAndroid
You want their, "onReceiveAd" method. Check it out, seems like exactly what you need.
There's no problem with preloading ads and not showing them until a specific time. You can use loadAd() for this. Just swap the visibility of the view when you want it to appear.
NOTE: If you do, you should set that particular ad to not "refresh every x seconds" on the mopub site. Otherwise, it will end up as unintentional ad fraud, since the ad will be refreshing itself while invisible(not to mention tank your CTR).
If you have other ads running in the app without this requirement, I'd recommend a separate ad unit for your sometimes-invisible one, so you can still do the refresh on the other one.

Get number of Home screens in Android?

I'm making a Live wallpaper for Android, and I want it scroll as user scroll the home screen. I can do that, but on some phones, user can choose the number of home screen. Is there anyway to get the number of home screen?
Thanks.
There is actually a way to know the number of home screens. The 'onOffsetsChanged' call provides to arguments for that porpouse: float xOffset and float xOffsetStep.
xOffset goes from 0 to 1 and xOffsetStep represents the step size for each home scree. So if you configure your home screen with 6 'desktops' xOffsetStep would be 0.2.
So the final way to check the number of screens must be done in that call (by default it sould be always 1) and then: (1/xOffsetStep) + 1.
Hope it helps!
There are many "home screen" apps, including, but not limited to, the ones that ship with every branded firmware. To that, you need to add all the market launchers, such as Go Launcher, Launcher Pro, etc. There is no standardised way to implement a launcher, so it will be quite difficult to find all the possible alternatives.
Most of the launchers do have a built-in option to scroll the wallpaper with every screen, although I can't tell you how well it works for live wallpapers.

How to create notification icon badge on Android apps (like iPhone)

I am very new to programming and would like to know what is the best way to go about creating a notification icon badge similar to the ones on the iPhone apps. This would be basically for creating a badge for the notifications that end up in the notification bar.
This is actually an answer from Mark Murphy:
For most phones, you use the number field of the Notification object.
See here:
http://github.com/commonsguy/cw-android/tree/master/Notifications/Notify1/
Now, there are a few phones by one major device manufacturer that have
a bug, whereby the number field is ignored. I am working on getting
them to fix it. So you can't absolutely rely on that red bubble being
there, though it will be on most phones.
Are you talking about a graphical icon? I created a transparent PNG using the gimp and pass that drawable id as the 1st argument to the Notification constructor.
Notification notification = new Notification(R.drawable.someicon,title,System.currentTimeMillis())
I know this is very old question. May be this link is helpful is you are still looking for answer. https://github.com/leolin310148/ShortcutBadger

Categories

Resources