How to Get Apps to Show Full Screen on Chromebook? - android

I've been making Android apps for a long time and can get them to open in full screen mode on every device except Chromebook. No matter what I do, they only open about half screen and a user has to click the "maximize" button to get them to open further.
Here is the code I use to try to get the apps full screen:
<item name="android:windowFullscreen">true</item>
in the relevant style in themes.xml
as well as
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
in MainActivity's onCreate() method.
I've also tried putting
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
in the application block of AndroidManifest.xml.
Is there something else I can do to get the apps to open full screen on Chromebook?
(I'm using HP Chromebook x360, if that helps)

So there is a section of the Android documentation for using Android on ChromeOS which makes reference to Window Management - Launch Size which seems appropriate.
Quoting from the documentation:
Use a launch size only in desktop environments. This helps the window manager to give you the proper bounds and orientation. To indicate a preferences when used in desktop mode, add the following meta tags inside the <activity>:
<meta-data android:name="WindowManagerPreference:FreeformWindowSize"
android:value="[phone|tablet|maximize]" />
<meta-data android:name="WindowManagerPreference:FreeformWindowOrientation"
android:value="[portrait|landscape]" />
Use static launch bounds. Use inside the manifest entry of your activity to specify a "fixed" starting size. See this example:
<layout android:defaultHeight="500dp"
android:defaultWidth="600dp"
android:gravity="top|end"
android:minHeight="450dp"
android:minWidth="300dp" />
Use dynamic launch bounds. An activity can create and use ActivityOptions.setLaunchBounds(Rect) when creating a new activity. By specifying an empty rectangle, your app can be maximized.
Note: These options work only if the activity started is a root activity. You can also do this using a springboard activity to clear the activity stack in the task with a new start.

Related

cordova/phonegap has quick loading screen on android

When ever I load my app on android I get a grey screen with the words "player needed"(the apps name) across the top for about a second before my app actually starts. It does not appear on the development testing app only when I do an actual build, and then only when I start the app. If I change windows back and forth it does not appear again. How can I remove this?example of grey screen
Thank you!
You could try this, worked for me, it's something about the MainActivity theme on Android.
In the "platforms\android" folder under your project, open the AndroidManifest.xml and search for android:theme inside the <activity> tag that contains android:name="MainActivity" and change the default value (that is android:theme="#android:style/Theme.DeviceDefault.NoActionBar") to android:theme="#android:style/Theme.Translucent". Save the file and build your project again, the grey screen should desapear.

My Android app rotates even if screen rotation is disabled in the OS. How can I fix this?

I am developing an Android app that has full support for landscape mode. All of my activities have the following properties set in the manifest:
android:configChanges="keyboardHidden|locale|orientation"
android:screenOrientation="sensor"
However, if I disable rotation in the phone's Screen settings, my app still rotates when the phone is rotated. This kind of bothers me; it seems like the whole point of a system-level setting is moot if it can be overriden by an individual app. How can I fix this so it follows the system-level setting while still behaving properly if screen rotation is enabled on the phone?
You could try using
android:screenOrientation="user"
You can try other way like this ,
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
apply these attributes after the activity name in AndroidManifest.xml file.
you can add android:screenOrientation="user" and make sure there is no SCREEN_ORIENTATION_SENSOR in the java code or manifest.

Problems while showing a full screen videoView & changing orientation

I have an activity which shows a full screen videoView (yet maintain the aspect ratio). It worked perfectly on Android 2.3.7, but i'm having some weird problems on Android 4 (and probably 3, i didn't check yet):
For some reason, if I set the theme to be full screen, without the titlebar (or action bar), i get a blue-ish (or white-ish?) gradient below the videoView, as shown here:
The relevant layout is here:
edit: on android 3 , it doesn't occur.
When I change the orientation from portrait to landscape, it re-loads the whole video from the beginning. On Android 2.3.7, it continued without any delay, as if nothing has changed.
The relevant manifest part is here:
<activity android:name=".activities.player_activity.PlayerActivity" android:configChanges="keyboardHidden|orientation"
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" android:screenOrientation="sensor"/>
Note that on Android 3, rotating the tablet doesn't do anything, so there is no orientation change.
How should I handle those problems ? The API demos don't seem to be updated to handle those cases.
My project was tested on: nexus one (android 2.3.7) , xoom (android 3) , galaxy S3 (android 4).
In order to fix number 1, I've simply changed the theme that doesn't have any background. Odd that it's this way on the device. Wonder if it's like this on other Android 4 devices. In order to create the theme, I've created a file "theme.xml" in the "res/values/" folder, and wrote there:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.FullScreenNobarsNoBackground" parent="#android:style/Theme.Holo.NoActionBar.Fullscreen">
<item name="android:windowBackground">#null</item>
</style>
</resources>
Of course I've also updated the manifest to use the new theme.
When you change the device orientation, the Dalvik kills the activity and create another, and garbage collector clean all the old stuff.
I suggest to you forces the application stay in horizontal mode, you can do that change the follow attribute in activity:
<activity android:screenOrientation="landscape" />
If you wanna the activy change the orientation, you must handler the change. You can read this documentation how to handling runtime changes.
I'm afraid I can't see the gradient you're talking about on that image. But if it is on the whole screen, then this is probably the standard background for Holo themes and you can just remove it using a custom theme.
As for the restarting on rotation, you could save the current time in onConfigurationChanged(..) and then use VideoView.seekTo(..) to then get it back to the correct time in an appropriate part of your code. However, I don't know why this should happen in ICS because you're not destroying the Activity.

Android ICS native lockscreen

I've been looking for the past 2 days on SW, google and so on. I'm looking for a way to implement an activity that comes with the native Android ICS lockscreen as the one shown in the screens below.
Those screens come from Player Pro but I noticed that also other players ( PlayerPro for instance ) have the same feature that looks exactly the same, that's why i think it's something native or at least, there is a common way to implement it.
So far I only managed to get and Activity that replace the lockscreen using these flags:
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
with a BroadCaseReciever on these events:
Intent.ACTION_SCREEN_ON
Intent.ACTION_SCREEN_OFF
Intent.ACTION_USER_PRESENT
My problem is that i want my activity to be shown with the lockscreen not replacing it. Do you guys know how to achieve this?
is there a native-hidden API to do this?
can you guys link me some sample that implement this particular feature?
thanks in advance ;)
I think you might be looking for the Audio Controls "remote view" (RemoteControlClient) API added in Android 4.0 (API level 14). I found the RemoteControlClient API in the Android developer docs that:
enables exposing information meant to be consumed
by remote controls capable of displaying metadata, artwork and media
transport control buttons.
(It was linked off of this page.)
Note: I have never used this API myself, so I apologize if this does not work for you.
You're almost doing it right. Keep doing what you do with the BroadcastReceiver. That's the way to go. For the Window, these are the flags you need to use:
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
Do not use FLAG_DISMISS_KEYGAURD
What these flags do: SHOW_WHEN_LOCKED allows your activity to show up on top of the lock screen. FLAG_NOT_TOUCH_MODAL allows touch events that are not on your activity to go to the other activities, ie, allows the user to unlock the screen. FLAG_DISMISS_KEYGUARD gets rid of the lock screen, so we do not use it.
Define this style in your res/values/styles.xml file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.FloatingTranslucent" parent="android:Theme.Translucent.NoTitleBar">
<item name="android:windowIsFloating">true</item>
</style>
</resources>
In your manifest, define your activity's style
<activity android:name=".SampleActivity" android:theme="#style/Theme.FloatingTranslucent">
...
</activity>
What this does is makes your activity completely see through and wrap content.
Now, your activity should be on top of the lock screen, allowing touch input to the lock screen and to your app, with your activity not full size.
Cheers.

Using user's current homescreen (w/ icons) in app

I want to use the user's current homescreen as an element of an app, including their icons and layout. I do not expect it to be dynamic, just a static image of their screen upon which the app can act. The "Cracked Screen" app does this like I'm thinking.
In researching, I've found ways to grab a screenshot (requires root) or grab the current wallpaper (doesn't include icons), but nothing yet about this particular issue.
Any ideas? Thanks!
Use the translucent theme. Set it in your AndroidManifest for the relevant activity like this:
<activity android:theme="#android:style/Theme.Translucent"
...>
This sets the users homescreen with it's icons as the background of the activity, your views float over that. Alternatively you can use #android:style/Theme.Translucent.NoTitleBar if you want to hide the title bar additionally.

Categories

Resources