as is clear from my question I want start activity from foreground service. in android 5-9 it will start but in android 10 has restrictions and I do not know what to do!
this is activity that need to be started:
public class Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarm_time);
// Important: have to do the following in order to show without unlocking
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
}
and manifest:
<activity android:name=".Activity"
android:showOnLockScreen="true"
android:screenOrientation="portrait"
android:autoRemoveFromRecents="true"
android:excludeFromRecents="true"
/>
Starting from android 10 in most cases it is not possible to open your activity from background service as they have added many restrictions to provide better experience to user .
Here are the Exceptions to the restriction
Here is reference link for same Exceptions to the restriction