how to remove statusbar animation when changing to fullscreen in Android - android

when i change my activity to fullscreen, the statusbar performs an
animation,but not disappear immediately. so how can i make the
statusbar disappear immediate ? if need to change framework , where is
it?

try android:theme="#android:style/Theme.NoTitleBar.Fullscreen" in the activity tag in your manifest file.
Edit:
Use requestWindowFeature(Window.FEATURE_NO_TITLE) in your onCreate() before you call setContentView () to set programmatically.

I have found solution.
we can out following code in activity from which we are creating and starting Intent
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Intent scanIntent = new Intent(this, SecondActivity.class);
startActivity(scanIntent);
By this it will hide status bar first then it will move to next activity.
Above code will require only when you are using single instance for second activity.
else you can apply solution given by Vineet Shukla

Related

Android: Black Screen between Activity

When I go one activity to another activity , between the transaction a Black screen is come for some seconds. I properly finish the activity before calling startActvity().
Am using android:theme="#android:style/Theme.Translucent" theme for my activity. Even though between the activity transaction a black screen is coming
Can any one please tell me how to resolve this
Thanks in advance :)
There is no need to finish activity before calling startActivity().
Make sure that you have set content view in the onCreate of called Activity and that you are not blocking UI thread (check onCreate, onStart and onResume if you have override them).
You don't need to manage finshing your activity, this will be managed automatically when the activity is no longer in view. Just use:
startActivity(new Intent(this, MyNextActivity.class));
And use this code in whatever method you are using to navigate the activity changes.
If you make sure your window is the background of your activities you can set the window background to a color other than black:
<item name="android:windowBackground">#drawable/window_background</item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#color/window_background"/>
</shape>
windowBackground in Android 6 (Marshmallow)
The other option is to manage transitions, so there is no gap between the end of the first transition and the beginning of the second. However, you have not mentioned transitions.
How to remove the delay when opening an Activity with a DrawerLayout?
for disable this default animation create one style:
<style name="noAnimTheme" parent="android:Theme">
<item name="android:windowAnimationStyle">#null</item>
</style>
and set it as theme for your activity in the manifest:
<activity android:name=".ui.ArticlesActivity" android:theme="#style/noAnimTheme">
</activity>
Assumption :-
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xyz);
// comment code here
}
If you go from activity A to B then try to comment code in OnCreate , OnResume in Activity B Like this and check what happen still black screen is coming or not.If coming then try to change theme.
If you have a finish() or FLAG_ACTIVITY_CLEAR_TASK - a blank screen may show up on pre ICS devices
To avoid this black screen you have to add one line in intent
overridePendingTransition (0, 0);
Example(kotlin):
val intent = Intent(applicationContext, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
overridePendingTransition (0, 0)
Example(Java):
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
overridePendingTransition (0, 0);

Is it possible to apply CLEAR_TOP flag for activity in manifest?

I want to have an activity which clears top (clearTop=true) whenever there is an intent to start that activity. Right now I have to control the activity start from every place and manually add (xamarin.android syntax) activity flag to intent:
intent.AddFlags(ActivityFlags.ClearTop);
Please advise how to put this behavior into manifest/attribute
Put attribute android:launchMode="singleTop" to your activity
more info here

Loading my transparent activity hides the keyboard

I manage some events in a background BroadcastReceiver. In some specific situations I need to launch an activity. This activity is supposed to be hidden. Nothing should be displayed to the user.
It works well but if the user is using the keyboard, typing something, the keyboard is hidden. If the user is using GMail, writing an email, then a "draft" is saved.
It seems like this activity gets to the top and stops the one the user is using even if it is invisible. Is there any way to solve this?
This how I declare the activity in manifest:
<activity
android:name=".MyInvisbleActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar">
</activity>
This is how I launch it:
Intent intent = new Intent(MyContext, MyInvisbleActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MyContext.startActivity(intent);
This is the MyInvisbleActivity onCreate():
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//setContentView(---); //This is not used
Window oWindow = getWindow();
oWindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
--do work--
}
Thank you!
Android provides a theme for this android:theme="#android:style/Theme.NoDisplay"
Alternatively it sounds like you might actually want a service. But youd need to provide more information on what you are trying to achieve

native calling screen animation stops when dialog activity display on screen

I have on dialog activity with 2 buttons which is being display when native caller id screen displays. Two buttons are click-able and also I can pick up and reject call by android native screen buttons.
Problem is when this dialog displays, animation of native call screen stops. I have seen this things in Truecaller app and also Current Caller Id app. I have also used following some codes
Manifest.xml
android:launchMode="singleInstance"
android:taskAffinity=""
android:theme="#android:style/Theme.Dialog"
android:windowAnimationStyle="#android:style/Animation.Translucent"
android:windowBackground="#android:color/transparent"
android:windowIsTranslucent="true"
And activity.java
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
getWindow().setFlags(LayoutParams.FLAG_NOT_FOCUSABLE,
LayoutParams.FLAG_NOT_FOCUSABLE);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
requestWindowFeature(Window.FEATURE_NO_TITLE);
and adding flags from intent call
Intent i1 = new Intent(this, activity.class);
i1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i1.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
i1.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
i1.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
i1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
I have tried lots of things to achieve this, How can I create dialog so caller id animation don't stop. Thanks in advance.
I implemented a solution that works well for me (and does not stop animation), here it is: https://github.com/inez/CustomIncomingCallScreen

Is there any way to remove notification/status bar, but not in onCreate?

As far as I know, it is possible to hide the notification/title bar, once the
activity is visible (has content) , But... maybe I'm wrong?
Is there any way to hide it after the activity is visible?
You can define the activity to use a theme that eliminates the notification/title bar. For instance, you can add this as an attribute to your <activity ... > tag in AndroidManifest.xml:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
The presence of a title cannot be changed once you have called setContentView(). The only way to hide the title bar after your activity has started is to restart the activity with a modified intent. Do something like this:
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.putExtra("NoTitle", true);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
Then in onCreate() test whether the "NoTitle" extra is present in the intent and make the appropriate call to requestWindowFeature() before calling setContentView().

Categories

Resources