Wednesday, 21 August 2013

Running without disrupting on going activity?

Running without disrupting on going activity?

Hi I am trying to display a popup through a textview without disrupting
the on going activity in the screen. I have been trying moving around and
researching and decided to use runinthread method. However, my popup
doesn't show. I tried using AsyncTask and could not get my popup without
interrupting on going activity. Any help is greatly appreciated. Here is
how I am doing right now:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.popups);
message = getIntent().getStringExtra("message");
messageView = (TextView) findViewById(R.id.message);
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
messageView.setText(message);
Popups.this.finish();
}
});
}
}, 0, 5000);
}
I generate the Popups on BroadcastReceiver like this:
Intent intent = new Intent(context, Popups.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("message", strMessage);
context.startActivity(intent);

No comments:

Post a Comment