How to enable Show on Lock Screen permission by default - android

My app needs to display activity over the lock screen, And that is not working particularly on xiaomi devices, After some research I found that there is need to enable Show On Lock Screen permission.
I found that some of the applications on play store has this permission enabled by default,I have done lots of research but not found anyway of doing the same, Please help me with this

the following code worked for me, give it a try
<activity
android:name=".activities.alarm"
android:launchMode="singleTask"
android:showOnLockScreen="true"
></activity>

Related

How to permanently disable car mode?

I'm running Android 7.1 and I cannot for the life of me figure out how to ensure "car mode" doesn't start when the device (honeywell CT60) is docked. I've already tried the following:
installing app "no dock"
installing app "car mode off"
getting app devs to add uiMode to the <ACITIVTY> element in the manifest.xml file.
None of these seem to work.
Does anyone have any advice or ideas?
Perhaps even an app that force the device to not go into car mode.
You're on the right track. According to Honeywell the app's AndroidManifest.xml has to be modified in the following way:
<manifest>
<application>
<activity android:configChanges="uiMode">
[...]
</activity>
</application>
</manifest>
This has to be added for each activity, where CAR_MODE should be disabled. It signals to the OS that the app will handle changes regarding the UiMode itself. Now instead of restarting the app to apply changes, the OS will leave handling this change up to the app.
If you want to find out how exactly it works, there already is a post explaining it. Alternatively you can find a guide about this topic at the Android Developer Docs.

Draw Over Other Apps ~ Disabled / Grayed Out ~

Android states i must ask for permission if my app wants to "Draw over other apps" when on Android v 6.0+. This permission can only be given manually by the user navigating to the appropriate Settings area.
When sent to Settings (via my app calling the intent) i noticed the "Draw over other apps" option for my app is always set to Disabled; it cannot be modified. Furthermore, if one were to navigate to the Apps permissions manually you'll notice the desired app isnt even listed in the "Draw over other apps" page making it impossible to adjust the setting.
I've already followed the baffling instructions by others to disable all the other apps listed then to try running my app again but to no luck. I've also tried restarting the emulator, factory reset, and other emulators. No luck.
Are there any other solutions to resolving this disabled issue?
Ok i discovered the problem and this is likely the same issue all others have had. Within my AndroidManifest.xml i forgot to include the SYSTEM_ALERT_WINDOW permission.
So add the following just before the application element:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
Problem solved. Everyone should ignore the ridiculous claim that you need to disable all the other Draw over apps or Force stop others. Completely unnecessary in my case.

Making Android app portrait only makes it one-way portrait

I've made my app portrait-only and it works successfully, however there seems to be a cache. I can only have this kind of orientation:
[
But I can't rotate it 180°, it just shows like this:
But if I leave the app, the screen rotates. So the problem is, it seems that the app is being set to one-way portrait, is there a way to fix it? Here's how I'm setting portrait-only in each activity:
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"
Is there an option to fix this?
Try using this instead...
android:screenOrientation="sensorPortrait"
If this doesn't work let me know!
Edit
So people see this, it only works with API 9+ as #AbAppletic said in the comments below.

Why Google glass ends activity when it goes to sleep?

I have started developing on Google glass but i found something very weird. Activity ends when Google glass goes to sleep? Can anyone help me on how can i stop the glass from killing the activity.
I was having a very similar issue. I also found a related question here: https://stackoverflow.com/questions/31318952
As noted in the comments by the poster, adding the immersive property to my AndroidManifest.xml fixed the issue and the Glass now always wakes up to my Activity.
<activity
android:name="com.my.app.ActivityName"
android:immersive="true">
</activity>

Android Emulator force closes when overriding screen orientation

I have an app where all activities have the orientation overritten to be portrait.
This is what a random activity declaration looks like on the Manifest:
<activity
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name"
android:name=".activities.LeaderboardActivity"
android:screenOrientation="portrait" >
</activity>
There's nothing else changed for that matter on the LeaderboardActivity.java.
That code runs just fine on my phone, but when I loaded up the emulator to get some screen shots, it keeps sending me the following error:
"The application Android keyboard (process com.android.inputmethod.latin) has stopped unexpectedly. Please try again"
When I click "Force close", nothing happens, the app keeps running but the error pops up again in less than 10sec, making it impossible to do anything.
Has someone else experienced that kind of problem before?
And it's not a specific problem with my emulator, because all members of my team are getting the same error on their pcs, but not on their phones.
EDIT:
My friend told me he encountered this same problem, and resolved it by opening the AVD manually before starting the app, and only call the app when it's fully loaded. I still haven't tried that, I'll update this when I test this method.
Why are you using android:configChanges="orientation|keyboardHidden" since you are forcing android to stay on portrait orientation? Maybe that's the problem.. did you tried to get it off?

Categories

Resources