일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- Algorithm
- Android
- 데이터
- ubuntu
- broadcastreceiver
- 알고리즘
- Jenknis
- 백준
- service
- data
- activity
- IntelliJ
- intent
- github
- 단축키
- 안드로이드
- vscode
- 16197
- mysql
- 데이터전달
- goland
- 두 동전
- git
- 큐빙
- spring
- insert
- 제어반전
- Java
- 프로그래머스
- 17837
- Today
- Total
목록데이터전달 (3)
해보자
Service → Activity ____Service.java 1 2 3 4 Intent intent = new Intent(getApplicationContext(), ____Activity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("id", id); startActivity(intent); ____Activity.java 1 2 Intent a_intent= getIntent(); String id = intent.getStringExtra("id");
BroadcastReceiver → Service ___Receiver.java Intent intent = new Intent(context, ____Service.class); intent.putExtra("id", id ); this.context.startService(intent); ___Service.java @Override public int onStartCommand(Intent intent, int flags, int startId) { String id = intent.getStringExtra("id"); return super.onStartCommand(intent, flags, startId); }
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"); }