I created an application in which I registered a broadcast receiver within my main class(Main Activity
) and whenever I receive something in my BroadcastReceiver
I want to update UI for e.g. I want to show an alert box or set some text view of my MainActivity
. I receive all the values in my receiver but unable to set them, can somebody help me so that I can update my UI in the BroadcastReceiver
.
My BroadcastReceiver class is inner class of MainActivity like this :-
public class MainActivity extends Activity {
..........
public static class NissanTabBroadcast extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
SharedPreferences shrd = context.getSharedPreferences("NissanGallery", context.MODE_WORLD_READABLE);
type = shrd.getString("type", "null");
badges = shrd.getString("badge_count", "null");
//badge_tips_text.setText(badges);
/*Editor edit = shrd.edit();
edit.remove("type");*/
Toast.makeText(context, "" + type + "
" + badge_tips_text.getText().toString(), Toast.LENGTH_LONG).show();
}
}
}
Any help will be appreciable
Thanks
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…