First of all, CONGRATS to my sister for graduating High School today!
Okay, now that that is out of the way, let’s talk about the progress.
I’ve edited most of the code.
Moved the whole update phone language part to a new class file that extends BroadcastReceiver instead of Activity. Since i’ll be using intents to do this stuff, I read a little about BroadcastReceivers and how they only live for as long as the onReceive() method is running. This fits the changing language plan much better than just sending an intent to an activity and have it go from there.
Now, time to talk about the hardships. I was struggling quite a lot on making the whole intent thing work. After a while, I found out I needed to declare intent-filters in the manifest.xml file. Afterwards, I thought it was smooth sailing from there, however, turns out I had put the WRONG intent-filters.
Definitely need to keep this in mind in the future. Especially since intents are a very major part of Android Apps. What I needed to do this time, was that I needed the intent-filter to have <action android:name=” .ChangeLocale” />. That part should be under the <receiver> tags.
In addition to that, to send the broadcast, I would need to create an intent and declare the class that I am sending the intent to.
Intent intent = new Intent(".ChangeLocale"); intent.putExtra("locale", new LocaleInfo(correctList.get(position)).getLanguageTag()); sendBroadcast(intent);
This should send out the intent broadcast. The manifest file will help me pick out the right receiver if it matches. Since it matches my ChangeLocale class, the intent is received and then I can use String localeCode = intent.getStringExtra(“locale”);
Anyway, that was all the bad news. The GOOD news though, is that I got it working.
Next time, I will start to design the widget appearance and that stuff.