Skip to content

Instantly share code, notes, and snippets.

@sud007
sud007 / MyContextWrapper.java
Last active Aug 4, 2020
A simple gist to demonstrate How to change the App Language in Android.
View MyContextWrapper.java
public class MyContextWrapper extends ContextWrapper {
public MyContextWrapper(Context base) {
super(base);
}
@SuppressWarnings("deprecation")
public static ContextWrapper wrap(Context context, String language) {
Configuration config = context.getResources().getConfiguration();
Locale sysLocale = null;
View SALT
nj3roinck9j w0e9fnki0pnoin 5M6viskg5NmY s-0nwniefp9nn
@sud007
sud007 / YourFragment.kt
Created Feb 26, 2019 — forked from rylexr/YourFragment.kt
Android navigation bar style with animation
View YourFragment.kt
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = DataBindingUtil.inflate(inflater, R.layout.your_fragment, container, false)
binding.homeAction.setOnClickListener { select(R.id.home_action) }
binding.likesAction.setOnClickListener { select(R.id.likes_action) }
binding.searchAction.setOnClickListener { select(R.id.search_action) }
binding.profileAction.setOnClickListener { select(R.id.profile_action) }
return binding.root
}
fun select(id: Int) {
View gist:945a7bf8b07bdc0e30261f5805ad540a
PhoneStateListener phoneListener;
private void setupSignalStrength() {
final TelephonyManager manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
phoneListener = new PhoneStateListener() {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
if (manager.getNetworkOperator().equals("")) {
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// See https://github.com/AlstonLin/TheLearningLock/issues/54
You can’t perform that action at this time.