简体   繁体   English

广播接收者打算进行某项活动?

[英]Intent from Broadcast receiver to an activity?

I have an app, that send SMS when button is clicked. 我有一个应用程序,当单击按钮时可以发送短信。 After thet I am expecting a answer SMS, so it goes like this: 之后,我希望收到一个SMS答复,所以它像这样:

  1. Button click -> SMS is send (done) 单击按钮->发送短信(完成)
  2. SMS reciver is listening for incoming SMS (done) SMS接收器正在侦听传入的SMS(已完成)
  3. After SMS is recived, Reciver is extracting Text from SMS and saves it to the text file on sdcard (done) 接收短信后,接收器将从短信中提取文本并将其保存到sdcard上的文本文件中(完成)
  4. After text is copied, i need to start new activity (not done) 复制文本后,我需要开始新的活动(未完成)

So can i start new activity from BroadcastReceiver after recived SMS is proccessed? 那么在收到短信后,我可以从BroadcastReceiver开始新的活动吗?

from receiver you can start the activity like this: 从接收方,您可以像这样开始活动:

Intent launch = new Intent(context, ActivityToLaunch.class);
launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(launch);

Answer is Yes. 答案是肯定的。 You can start an activity in your BroadcastReceiver . 您可以在BroadcastReceiver启动活动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM