Change language in app

Resources res = activity.getResources(); DisplayMetrics dm = res.getDisplayMetrics(); android.content.res.Configuration conf = res.getConfiguration(); Locale locale = new Locale(“vi”); Locale.setDefault(locale); conf.setLocale(locale); res.updateConfiguration(conf,…

Read More

Check if service is running

private boolean isMyServiceRunning(Class<?> serviceClass) { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals(service.service.getClassName())) { return…

Read More

Change color of search view

EditText searchEditText = (EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text); searchEditText.setTextColor(ContextCompat.getColor(App.getInstance().getApplicationContext(), color)); searchEditText.setHintTextColor(ContextCompat.getColor(App.getInstance().getApplicationContext(), color));

Read More