I have an activity that I want not be seen in the Recents items. I have used the following in my Manifest file :
<activity
android:name=".WidgetLayout"
android:excludeFromRecents="true"
android:launchMode="singleInstance"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppTheme.Dialog">
It works perfectly well on all android versions but when I try it on Lollipop (SDK 21) it shows up always in the Recent items. So is it an OS bug as stated by many or I have made some error. Is there a solution to the problem if yes then how can I solve it ?
This is a known issue into Android 5.0, since L preview.
Try with android:taskAffinity
android:taskAffinity=".WidgetLayout"
android:excludeFromRecents="true"
You Should try adding android:autoRemoveFromRecents="true"
Related
Different configChanges for different android os version for single activity
<activity
android:name=".Activity_JoinMeeting"
android:configChanges="orientation|screenSize|layoutDirection|locale"
android:screenOrientation="landscape"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustPan|stateHidden"/>
configChanges for android OS 23 I want set set 4 properties and configChanges for android OS above 23 I want set 2 properties
how can I achive it
You can define two different activity in AndroidManifest file one for above android api 23 and other for rest android apis.
and launch that activies after checking api,
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP){
}
You can check the answer of aorlondo in this post and maybe try this solution with each properties you want to change.
When Android backgrounds an application it creates a screenshot of the current screen. The screenshot is displayed when you click the Overview button.
Is there a way to prevent this backgrounding screen shot (as if I'd used FLAG_SECURE), but allow the users to take screenshots?
You can configure not to show your activity in recent list. Add following code in manifest :
<activity
.....
android:excludeFromRecents="true"
...../>
Or from java code startActivity with flag:
intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
Or,
<activity
.....
android:noHistory="true"
...../>
Try this https://stackoverflow.com/a/49442984/5939067 .
The solution above simply sets the secure flag when your app goes background, and clears it when it resumes(so you can take the screenshot while using the app).
It works perfectly for me. I tested with Samsung Galaxy 9+(Android 9), LG V30(Android 8) and LG G7 ThinQ(Android 8).
I am using facebook sdk in my app. In order not to show the solo progress bar when facebook button is clicked, I am using:
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="#android:style/Theme.NoDisplay"
</activity>
However, I think for devices with api 23+ this causes a crash:
"com.facebook.FacebookActivity did not call finish() prior to onResume() completing"
Someone said here:Activity did not call finish? (API 23) by writing:
#Override
protected void onStart() {
super.onStart();
setVisible(true);
}
in the problematic activity, they solved the issue. But since I cannot edit FacebookActivity, is there any alternative solution?
Facebook have changed their instructions for initially setting up your project. Just change the theme for the com.facebook.FacebookActivity to #android:style/Theme.Translucent.NoTitleBar.
See javadoc of windowNoDisplay :
(...)your activity must immediately quit without waiting for user interaction(...)
So exception is correct, your use case does not match windowNoDisplay.
This is platform bug.
If you have been using Theme.NoDisplay in one or more activities in
your app, and you have not tested them on Android 6.0 yet, I recommend
that you do so soon. An undocumented regression in Android 6.0 will
cause some of those activities to crash upon launch, if your
targetSdkVersion is 23 or higher.
See this blog post: https://commonsware.com/blog/2015/11/02/psa-android-6p0-theme.nodisplay-regression.html
I have used following code in activity onCreate() to lock view only to landscape mode, it is perfectly working on device but not working on emulator, Since i dont have a device now it's hard to develop
code :
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
Please help
Try this:
android:screenOrientation="sensorLandscape"
Put this Code[Attribute] in Activity tag of AndroidManifest.xml file it should work.
In your manifest file simply add
<activity
android:name="yourActivity name"
android:screenOrientation="portrait" >
</activity>
Apologies if this is too obvious.. You have to manually put your emulator in landscape mode, I think. I think it's the F9 key, but it's been a while since I've done that.
Try this way, hope this will help you.
Define this attribute "android:screenOrientation="landscape"" as your activity in AndroidManifest.xml
Try this
Put below line of code in your manifest
<activity>
android:screenOrientation="landscape"
</activity>
It works for me....
I'm trying to get the screen rotation event. For that I'm using "OnConfigurationChanged".
The problem is my Activity definition which looks like
[Activity(ConfigurationChanges = global::Android.Content.PM.ConfigChanges.Orientation | global::Android.Content.PM.ConfigChanges.KeyboardHidden)]
I'm not able to provide the configuration global::Android.Content.PM.ConfigChanges.SreenSize which leads to the problem, that OnConfigurationChanged is not called.
My workaround is to add to the configuration to the AndroidManifest.xml which is kind of a hack.
<activity
android:name="mpa.gui.android.activities.HomeActivity"
android:configChanges="orientation|keyboardHidden|screenSize">
</activity>
I'm using
- Visual Studio 2012.
- My android project targets API level is 17
- Minimum Android target is set to Android 2.3
the AndroidManifest also configures this
Any idea why i can't configure the ScreemSize in my Activity?
Any help is appreciated.
You need to OR Android.Content.Pm.ConfigChanges.ScreenSize to trigger the onConfigurationChanged event for screen orientation changes in versions of Android higher than API level 13.
EG:
[Activity(Label = "MyActivity", ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation|Android.Content.PM.ConfigChanges.ScreenSize)]
Source:
https://stackoverflow.com/a/7366180/1099111