【发布时间】:2014-03-06 11:34:54
【问题描述】:
如何使用广播接收器启动/午餐片段 例如 : 如果我需要 start/luanch 活动,我可以使用 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();
}
}
但我不知道片段怎么样
【问题讨论】:
标签: android android-fragments broadcastreceiver