I have an alarm set and receive alarms when part of the job, then I saved with the alarm message Had set the string. But when I do not set this string on the UI
It will show the first code string that identifies the UI:
public class extends ShowAlm Activity {private static string Messtiar = "Jedjedjed"; Public Fixed Zero Setmester (String Mascot) {MessStr = messStr; } @ Override Crate on Public Zero (Bundle Saved Instantstate) {Super.Nought (Saved Instantstate); SetContentView (R.layout.showalm); Toast. Make Text (this, "Message" + MessStr, toast.LENGTH_SHORT). Show (); } Then to test it without alarm, I put a button on another class to make the call above and works as expected:
< code> btnplot.setOnClickListener (new button. OnClickListener () {@Override on public void (see V) {ShowAlm.setMessStr ( "AAA"); effect intent1 = new intent (context, ShowAlm.class); intent1.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK | effect. FLAG_ACTIVITY_CLEAR_TOP); Sndrbkprarnbhikta (Intentl); // Testalarm (); // means intended = new intent (VkgetContext (), auto-integer 4. class ); // Start (intent);}}); Here is the problem, the same code as the button above, but does not work in the receiver. String is not set.
public class alarm Risevr extends broadcast receiver {@ override response to public spaces (REFERENCES intended effect) {try {bundle bundle = intent.getExtras ()); String message = bundle.gate string ("alarm_smotion"); System.out.println ("message =" + message); ShowAlm.setMessStr ("AAA"); Intent1 = new intent (reference, ShowAlm.class); Intent1.addFlags (intestine. FLAG_ACTIVITY_N_T_TT); FLAG_ACTIVITY_CLEAR_TOP; Context.startActivity (intent1); } Catch (Exception e) {}} So when the show up a second code that Messtiar default values I I also tried to coding "AAA" as the string, But it did not help
so the end result is that the log shows that the string is, but when the UI is shown the string is the default.
Thoughts?
I think the problem is that its stable variable is when the receiver starts a new activity, it The class can be reloaded, and static will be started for "ZZZ". The proper way to do this is to put the string in intact extraction.
Public Waste Create (Bundled Saved Instance) {super.onCreate (savedInstanceState); SetContentView (R.layout.showalm); I = getIntent (); MessStr = i.getStringExtra ("AlarmSace", blank); If (mestrate! = Null) {toast. Make Text (this, "Message", + MassAstrate, Toast. LNNGHHORT). Show (); }} Public void on (contextual reference, intent to intent) {attempt (intent1 = new intent (reference, ShowAlm.class); Intent1.addFlags (intestine. FLAG_ACTIVITY_N_T_TT); FLAG_ACTIVITY_CLEAR_TOP; Intent1.putExtra ("alarm message", "AAA"); Context.startActivity (intent1); } Hold (exception e) {}}
Comments
Post a Comment