해보자

[Android] Activity에서 BroadcastReceiver로 데이터 전달 본문

ANDROID

[Android] Activity에서 BroadcastReceiver로 데이터 전달

안댕 2020. 2. 17. 23:04

Activity → BroadcastReceiver

____Activity.java

intent = new Intent(this, ____Receiver.class);
String id;
intent.putExtra("id", id);
sendBroadcast(intent);

____Receiver.java

@Override
public void onReceive(Context context, Intent intent) {
    String id = intent.getStringExtra("id");
}