广播员开放主动
我的代码打开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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从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