I am trying to display a window from service but don't getting it how to do this
Here is my code--
In onStart
method of Service
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.main1, null);
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.type = 2002;
params.format = 1;
params.flags = 40;
params.height = WindowManager.LayoutParams.FILL_PARENT;
params.width = WindowManager.LayoutParams.FILL_PARENT;
manager.addView(view, params);
/** just a timer *****/
textView = (TextView) view.findViewById(R.id.textView1);
final Timer t = new Timer("hello", true);
t.schedule(new TimerTask() {
@Override
public void run() {
textView.post(new Runnable() {
public void run() {
seconds++;
if (seconds == 60) {
seconds = 0;
minute++;
}
if (minute == 60) {
minute = 0;
hour++;
}
textView.setText(""
+ (hour > 9 ? hour : ("0" + hour)) + " : "
+ (minute > 9 ? minute : ("0" + minute))
+ " : "
+ (seconds > 9 ? seconds : "0" + seconds));
}
});
}
}, 1000, 1000);
view.findViewById(R.id.stop).setOnClickListener(
new OnClickListener() {
public void onClick(View v) {
t.cancel();
}
});
But nothing shown up. How can i display my views in window from service?