Dopo aver predisposto windowManager e i WindowManager.LayoutParams si istanzia un Layout e si aggiunge alla finestra.
@Override
public int onStartCommand(Intent intent, int flags, int startId){
windowManager=(WindowManager)getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams wParams=new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT
);
newLayout=new RelativeLayout(this);
windowManager.addView(newLayout,wParams);
.....
E quindi si inflata il layout voluto al posto di quello già messo.
LayoutInflater layoutInflater=(LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
layoutInflater.inflate(R.layout.layout,newLayout);
Ecco il tutto:
@Override
public int onStartCommand(Intent intent, int flags, int startId){
windowManager=(WindowManager)getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams wParams=new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT
);
newLayout=new RelativeLayout(this);
windowManager.addView(newLayout,wParams);
LayoutInflater layoutInflater=(LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
layoutInflater.inflate(R.layout.layout,newLayout);
return START_NOT_STICKY;
}
Nessun commento:
Posta un commento