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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…