广播员开放主动

发布于 2025-01-23 10:21:31 字数 850 浏览 3 评论 0原文

我的代码打开Main Activity并在时间结束后显示通知 广播员 通知良好,但主动脉没有显示我的手机Android 10 代码

        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());

这是问题的

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤寂小茶 2025-01-30 10:21:31

从Android 10(API 29)开始,您无法再从Brockatreceiver等背景过程开始活动。

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文