gpt4 book ai didi

android - 如何从服务类调用 Activity 类

转载 作者:太空狗 更新时间:2023-10-29 15:49:20 25 4
gpt4 key购买 nike

在我的应用程序中有一个服务类,需要从该服务类调用一个 Activity 类,但每次调用 Activity 类时它都会向我显示一条消息应用程序没有响应,下面是我的代码..

public class MyAlarmService_Movie extends Service {
@Override
public void onCreate() {
super.onStart(intent, startId);
Intent in=new Intent().setClass(MyAlarmService.this,Reminder.class);
startActivity(in);
}
}

最佳答案

在开始 Intent 之前给 in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

关于android - 如何从服务类调用 Activity 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5015507/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com