'open MainActivity by BroadcastReceiver

my code to open MainActivity and show NOTIFICATION after the time is end by AlarmManager and BroadcastReceiver the NOTIFICATION go fine but the MainActivity doesn't shown my phone android 10 this the code

        Intent launch_intent = new  Intent(context, MainActivity.class);
        launch_intent.setComponent(new 
        ComponentName("com.example.mysajedn","com.example.mysajedn.MainActivity"));
        launch_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_SINGLE_TOP
            | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
            |Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
 
       launch_intent.addCategory(Intent.CATEGORY_LAUNCHER );
       context.startActivity(launch_intent);

    NotificationHelper notificationHelper = new NotificationHelper(context);
    NotificationCompat.Builder nb = notificationHelper.getChannelNotification();
    notificationHelper.getManager().notify(1, nb.build());

where the problem



Solution 1:[1]

Beginning in Android 10 (API 29), you can no longer start activities from a background process like a BroadcastReceiver.

https://developer.android.com/guide/components/activities/background-starts

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dan Harms