I have created an app that applies a coloured filter over the screen. I would like to be able to change the colour of the filter by pressing buttons. Changing the background colour in the xml file works, but when I try changing it in a service it does not change colour. I am getting no errors but the colour does not change. I think that because I am adding the view with windowmanager and not setting it with setContentView
, it might not apply the colour changes. Here is the code of my service, I know the service is being called because the Log.d(TAG,"onCreated");
is showing up in the logcat. By the way, I have tried changing the colour of root
instead of bView
, but I end up with the same result.
public class ChangeColor extends Service {
public static final String TAG = "ChangeColour";
View mOverlayView;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mOverlayView = inflater.inflate(R.layout.overlay_view, null);
LinearLayout bView = (LinearLayout) mOverlayView.findViewById(R.id.lin);
if (bView != null) {
View root = bView.getRootView();
bView.setBackgroundColor(Color.parseColor("#000000"));
Log.d(TAG, "onCreated");
}
return START_NOT_STICKY;
}
}
See my old post if you would like to see the service and activity that is adding the view. If anybody has any ideas let me know! Thanks.