В моем приложении пользователь может изменить тему приложения по сравнению с настройкой внутри приложения.Это работает во всех других экранах внутри приложения.Но это не работает только для заставки.Когда пользователь меняет тему приложения, я загружаю один класс, который имеет только функциональные возможности для вызова экрана-заставки.
До сих пор у меня есть: -
public class ActivitySplash extends AppCompatActivity {
Preferences pref;
MediaPlayer mySong;
int maxVolume = 100;
Constant constant;
SharedPreferences app_preferences;
int appTheme;
int themeColor;
int appColor;
LinearLayout relative_layout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// AppEventsLogger.activateApp(this);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
app_preferences = PreferenceManager.getDefaultSharedPreferences(this);
appColor = app_preferences.getInt("color", 0);
appTheme = app_preferences.getInt("theme", 0);
System.out.println("adweff"+appColor+"dfdscsbv"+appTheme);
themeColor = appColor;
constant.color = appColor;
if (themeColor == 0){
setTheme(Constant.theme);
}else if (appTheme == 0){
setTheme(Constant.theme);
}else{
setTheme(appTheme);
}
setContentView(R.layout.activity_splash);
HttpsTrustManager.allowAllSSL();
Fabric.with(this, new Crashlytics());
FacebookSdk.sdkInitialize(getApplicationContext());
relative_layout=(LinearLayout) findViewById(R.id.relative_layout);
/* if (appColor==(-16537100)){
System.out.println("called=="+Constant.color);
relative_layout.setBackgroundColor(Color.parseColor("#5ecbf4"));
}*/
if (appColor != 0) {
if (appColor == -16537100) {
relative_layout.setBackgroundColor(Color.parseColor("#0f95dc"));
} else {
relative_layout.setBackgroundResource(R.color.colorPrimary);
}
// relative_layout.setBackgroundColor(Constant.color);
}
SharedPreferences prefss = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor edts = prefss.edit();
edts.putString("extra", "Yes");
edts.commit();
Intent intent = new Intent(getApplicationContext(),
MyAlarmService.class);
sendBroadcast(intent);
// mySong.start();
pref = new Preferences(ActivitySplash.this);
new Handler().postDelayed(new Runnable() {
// Using handler with postDelayed called runnable run method
@Override
public void run() {
if (appColor != 0) {
if (appColor == -16537100) {
relative_layout.setBackgroundColor(Color.parseColor("#0f95dc"));
} else {
relative_layout.setBackgroundResource(R.color.colorPrimary);
}
//relative_layout.setBackgroundColor(Constant.color);
}
if (pref.getStringPreference(ActivitySplash.this, "login").equalsIgnoreCase("1")) {
Intent intent = new Intent(ActivitySplash.this, ActivityHome.class);
startActivity(intent);
finish();
} else {
Intent intent = new Intent(ActivitySplash.this, ActivityLoginRegistration.class);
startActivity(intent);
// mySong.release();
finish();
}
}
}, 3 * 1000); // wait for 5 seconds
}