由网友(琴心剑魄今何在)分享简介:我如何使用广播接收器,启动/午餐片段例如 :如果我需要为启动/ luanch 活动,我可以使用意向 How can I use broadcast receiver to start/lunch fragmentfor example :if I need to start/luanch activity ,...
我如何使用广播接收器,启动/午餐片段 例如 : 如果我需要为启动/ luanch 活动,我可以使用意向
How can I use broadcast receiver to start/lunch fragment for example : if I need to start/luanch activity , I can use intent :
public void onReceive(final Context context, Intent intent) {
this.context = context;
this.intent = intent;
try {
Bundle bundle = intent.getExtras();
int messageID = bundle.getInt("id");
intent = new Intent(context, GetAlarm.class);
intent.putExtra("id",messageID);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (Exception e) {
Toast.makeText(context, "There was an error ", Toast.LENGTH_SHORT)
.show();
e.printStackTrace();
}
}
但我不知道怎么样片段
but I don't know how about fragment
推荐答案
您必须 luanch 的意图和 putextera 和 sendactivity 。 然后,你可以从活动启动片段。
You must luanch intent and putextera and sendactivity. Then you can launch fragment from activity.
相关推荐
最新文章