일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Java
- ubuntu
- 17837
- vscode
- 데이터
- broadcastreceiver
- activity
- Android
- 데이터전달
- Algorithm
- goland
- Jenknis
- spring
- IntelliJ
- data
- 16197
- 알고리즘
- 안드로이드
- 백준
- service
- 단축키
- 프로그래머스
- 큐빙
- 두 동전
- intent
- 제어반전
- github
- mysql
- insert
- git
- Today
- Total
목록activity (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");
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"); }
A Activity → B Activity A Activity Intent outIntent = new Intent(getApplicationContext(), ActivityB.class); outIntent.putExtra("data_1", data1); outIntent.putExtra("data_2", data2); setResult(RESULT_OK, outIntent); finish(); B Activity Intent intent = getIntent(); int data1 = intent.getExtras().getInt("data_1"); int data2 = intent.getExtras().getInt("data_2");