I have an issue its error: Binary XML file line #196: tag requires a 'drawable' attribute or child tag defining a drawable
This error occurs sometimes and sometimes not for the same actions where I use animation-list. It causes a crash. After the crash, I reopen the app and do the same thing, but I don't have that type of error.
An error occurred approximately one time every 10 actions are the same. I can't get what is wrong and why it occurs rarely and not all time.
Every attempt is after creating activity.
My java code:
package com.edulab.akiciokuma;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
public class AnimationActivity extends AppCompatActivity {
private MediaPlayer player;
private AnimationDrawable running;
private ImageView anime;
private String animwhich, strategy, condition;
private int level;
private FirebaseFirestore firebaseFirestore =
FirebaseFirestore.getInstance();
private String[] animalIntro = {"tosbaameeting", "zipzipintro",
"foxintro", "atintro", "deveintro", "cheetahintro"};
private String[] animalModel = {"tosbaamodel", "zipzipmodel",
"foxmodel", "atmodel", "devemodel", "cheetahmodel"};
private String[] animalModel2 = {"tosbaamodel2", "zipzipmodel2",
"foxmodel2", "atmodel2", "devemodel2", "cheetahmodel2"};
private String[] animalReread = {"tosbaareread", "zipzipreread",
"foxreread", "atreread", "devereread", "cheetahreread"};
private String[] animalReread2 = {"tosbaareread2", "zipzipreread2",
"foxreread2", "atreread2", "devereread2", "cheetahreread2"};
private String[] animalReread3 = {"tosbaareread3", "zipzipreread3",
"foxreread3", "atreread3", "devereread3", "cheetahreread3"};
private String[] animalshutup = {"tosbaailk6", "zipzipgozuacik2",
"foxacik5", "atacik6", "deveacik4", "cheetahacik5"};
private boolean intro = false;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animation);
initializeVariables(); //initializing variables
if(animwhich.equals("intro")){
intro = true;
setvideo(animalIntro[(int) Math.floor(level/12.1)]);
}
else{
if(animwhich.equals("model")) {
if(strategy.equals("x"))
setvideo(animalModel2[(int) Math.floor(level/12.1)]);
else
setvideo(animalModel[(int) Math.floor(level/12.1)]);
}else {
if (animwhich.equals("reread")) {
switch (Integer.parseInt(condition)){
case 2:
setvideo(animalReread2[(int)
Math.floor(level/12.1)]);
break;
case 3:
setvideo(animalReread3[(int)
Math.floor(level/12.1)]);
break;
default:
setvideo(animalReread[(int)
Math.floor(level/12.1)]);
break;
}
}
}
}
}
private void initializeVariables() {
animwhich = configureText("animwhich", "model");
strategy = configureText("strategy", "y");
condition= configureText("condition", "1");
level = configureNumber("level");
anime = findViewById(R.id.imageView);
}
private void setvideo(final String file) {
anime.setImageDrawable(getResources().getDrawable(getResources().
getIdentifier("drawable/" + file, null,
getPackageName())));
running = (AnimationDrawable) anime.getDrawable();
running.start();
if (player == null) {
player = MediaPlayer.create(this,
getResources().getIdentifier(file, "raw", getPackageName()));
player.setOnCompletionListener(new
MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mp) {
stopPlayer();
}
});
}
if (player != null) {
player.start();
}
}
private void stopPlayer() {
if (player != null) {
player.release();
player = null;
running.stop();
final Intent getData = getIntent();
anime.setImageDrawable(getResources().getDrawable(getResources().
getIdentifier("drawable/" + animalshutup[(int)
Math.floor(level/12.1)], null, getPackageName())));
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
#Override
public void run() {
final Intent intent;
if (animwhich.equals("reread")) {
intent = new Intent(AnimationActivity.this,
Reread1Activity.class);
}
}
}
}, 2000);
}
}
#Override
protected void onStop() {
super.onStop();
stopPlayer();
}
private int configureNumber(String tag){
Intent getData = getIntent();
int value;
if(getData.getStringExtra(tag)==null)
value=1;
else
if(getData.getStringExtra(tag).matches("-?([1-
9]\\d*)")&&Integer.parseInt(getData.getStringExtra(tag))>0)
value= Integer.parseInt(getData.getStringExtra(tag));
else
value=1;
return value;
}
private String configureText(String tag, String deflt){
Intent getData = getIntent();
String value;
if(getData.getStringExtra(tag)==null)
value=deflt;
else
if(getData.getStringExtra(tag).isEmpty())
value=deflt;
else
value= getData.getStringExtra(tag);
return value;
}
}
My screen xml code is below:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
app:srcCompat="#drawable/arkaplansabit"
android:id="#+id/backgr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</FrameLayout>
My animation list xml code is below:
<?xml version="1.0" encoding="utf-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="1600"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="300"/>
<item android:drawable="#drawable/zipzipgozukapali1"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali2"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali3"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali4"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali5"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali6"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="300"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="400"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozukapali1"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali2"
android:duration="50"/>
<item android:drawable="#drawable/zipzipgozukapali3"
android:duration="50"/>
<item android:drawable="#drawable/zipzipgozukapali4"
android:duration="50"/>
<item android:drawable="#drawable/zipzipgozukapali5"
android:duration="50"/>
<item android:drawable="#drawable/zipzipgozukapali6"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="1100"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="500"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozukapali1"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali2"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali4"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali5"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali6"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="800"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="500"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozukapali1"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali2"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali3"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali4"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali5"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozukapali6"
android:duration="100"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="400"/>
<item android:drawable="#drawable/zipzipgozuacik1"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik3"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik4"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik5"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik6"
android:duration="200"/>
<item android:drawable="#drawable/zipzipgozuacik2"
android:duration="20000"/>
Please help me with this issue.
THANK YOU
I wrote a code for setting a theme for activities setTheme(R.style.darkTheme); but i don't know how to write in fragments activity to set the theme.The code is for activities
if(sharedPref.loadNightModeState()==true)
{
setTheme(R.style.darkTheme);
}
else {
setTheme(R.style.AppTheme);
}
This is my style.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="backgroundcolor">#color/background</item>
<item name="textcolor">#color/textcolor</item>
<item name="buttoncolor">#color/red</item>
</style>
<style name="darkTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#212121</item>
<item name="colorPrimaryDark">#000000</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="backgroundcolor">#303030</item>
<item name="textcolor">#color/white</item>
<item name="buttoncolor">#color/red</item>
</style>
</resources>
This is my fragment code
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_state, container, false);
sharedPref=new SharedPref(getActivity());
if(sharedPref.loadNightModeState()==true)
{
setTheme(R.style.darkTheme);
}
else {
setTheme(R.style.AppTheme);
}
return view;
}
error is coming in this setTheme(R.style.AppTheme) line .
I have set up a ListPreference with different values for the user's dark mode preference. Right now, I just want the app to work with the new dark mode implementation introduced in Android Q. If I set the system dark mode, the app changes because I have enabled isforcedarkallowed in styles.xml.
SettingsFragment:
public static class SettingsFragment extends PreferenceFragmentCompat {
#Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.root_preferences, rootKey);
PreferenceScreen screen = getPreferenceScreen();
final ListPreference listPreference = (ListPreference) findPreference("theme");
Preference preference = (Preference) findPreference("notq");
int api = Integer.valueOf(android.os.Build.VERSION.SDK_INT);
if (api > 28) {
screen.removePreference(preference);
}
if (api < 29) {
screen.removePreference(listPreference);
}
listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
#Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
listPreference.setValue(newValue.toString());
theme = String.valueOf(listPreference.getEntry());
Log.d("debug", theme);
if (theme.equals("Light")) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
}
if (theme.equals("Dark")) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_YES);
}
if (theme.equals("System default")) {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM);
}
return true;
}
});
}
}
Arrays.xml (values for dark mode preference)
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Reply Preference -->
<string-array name="theme_entries">
<item>Light</item>
<item>Dark</item>
<item>System default</item>
</string-array>
<string-array name="theme_values">
<item>light</item>
<item>dark</item>
<item>default1</item>
</string-array>
</resources>
My listpreference:
<ListPreference
android:id="#+id/list"
app:entries="#array/theme_entries"
app:entryValues="#array/theme_values"
app:key="theme"
app:title="#string/theme_title"
app:useSimpleSummaryProvider="true" />
And the app theme I'm using (styles.xml):
<style name="AppTheme2" parent="Theme.AppCompat.DayNight.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:forceDarkAllowed" tools:targetApi="q">true</item>
<item name="android:isLightTheme" tools:targetApi="q">true</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#FFFFFF</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
Any suggestions?
In your styles.xml you should not take Theme.AppCompat.DayNight.DarkActionBar as a parent while you enabled forceDarkAllowed. Change that to Theme.AppCompat or Theme.MaterialComponents. You cannot inherit from a daynight theme while forceDarkAllowed is set to true. You can read about that here https://developer.android.com/guide/topics/ui/look-and-feel/darktheme section forcedark.
String theme = String.valueOf(listPreference.getEntry());
Should work fine, you just didn't declare theme as a string
:)
I'm using PreferenceFragmentCompat for preferences and when I change theme preference using ListPreference to a dark theme and recreate activity text stays dark and becomes not visible. If I reopen this fragment text becomes white, but it returns to black color on orientation change
Here is my styles:
<style name="AppThemeLight" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="preferenceTheme">#style/preferenceLight</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:textColorPrimary">#color/primaryText</item>
<item name="android:textColorSecondary">#color/secondaryText</item>
</style>
<style name="AppThemeDark" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="preferenceTheme">#style/preferenceDark</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowBackground">#color/primaryText</item>
<item name="android:textColorPrimary">#color/primaryTextDark</item>
<item name="android:textColorSecondary">#color/secondaryText</item>
</style>
<style name="preferenceLight" parent="PreferenceThemeOverlay.v14.Material">
<item name="android:textColor">#color/primaryText</item>
<item name="android:textColorPrimary">#color/primaryText</item>
<item name="android:textColorSecondary">#color/secondaryText</item>
</style>
<style name="preferenceDark" parent="PreferenceThemeOverlay.v14.Material">
<item name="android:textColor">#color/primaryTextDark</item>
<item name="android:textColorPrimary">#color/primaryTextDark</item>
<item name="android:textColorSecondary">#color/secondaryText</item>
</style>
and fragment
class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener{
private lateinit var advertisePreferences: AdvertisePreferences
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
advertisePreferences = AdvertisePreferences(context!!)
}
override fun onResume() {
super.onResume()
(activity as AppCompatActivity).supportActionBar?.title = getString(R.string.settings)
preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this)
}
override fun onPause() {
super.onPause()
preferenceManager.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.app_preferences, rootKey)
}
override fun onPreferenceTreeClick(preference: Preference): Boolean {
when(preference.key){
}
return super.onPreferenceTreeClick(preference)
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
when(key){
getString(R.string.theme_key) -> {
activity?.recreate()
}
}
}
}
It seems it was bug in library. It now fixed in androidx.preference:preference:1.1.0-alpha02
I have one activity that show my logo and i want change to second activity after that two seconds automatically.
I have done this but it doesn´t apply the effect.
Logo.java
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.logo_layout);
new Handler().postDelayed(new Runnable()
{
#Override
public void run()
{
Intent i = new Intent(Logo.this, Loggin.class);
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(Logo.this);
startActivity(i, options.toBundle());
finishAfterTransition();
}
}, TIME);
}
res/transition/my_trasition.xml
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<fade
android:duration="1000">
</fade>
</transitionSet>
res/values/styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppFullScreen" parent="#style/Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowEnterTransition">#transition/transicion</item>
<item name="android:windowExitTransition">#transition/transicion</item>
<item name="android:windowAllowEnterTransitionOverlap">false</item>
<item name="android:windowAllowReturnTransitionOverlap">false</item>
</style>