You can either change
minSdkVersion 16
with
minSdkVersion 23
or import android.support.annotation.RequiresApi;
to your class and this statement
@RequiresApi(api = Build.VERSION_CODES.M)
to the activity you used setForground
method in it.
Note that M
in @RequiresApi(api = Build.VERSION_CODES.M)
stands for API 23
and you can use each one of the items below that each one stand for a specific API instead of M
BASE 1
BASE_1_1 2
CUPCAKE 3
DONUT 4
ECLAIR 5
ECLAIR_0_1 6
ECLAIR_MR1 7
FROYO 8
GINGERBREAD 9
GINGERBREAD_MR1 10
HONEYCOMB 11
HONEYCOMB_MR1 12
HONEYCOMB_MR2 13
ICE_CREAM_SANDWICH 14
ICE_CREAM_SANDWICH_MR1 15
JELLY_BEAN 16
JELLY_BEAN_MR1 17
JELLY_BEAN_MR2 18
KITKAT 19
KITKAT_WATCH 20
LOLLIPOP 21
LOLLIPOP_MR1 22
M 23
N 24
N_MR1 25
O 26
CUR_DEVELOPMENT 10000