Android

Intent

  Intent 로 값 전달하기   // 전달하는 쪽 Intent intent = new Intent(this, ResultActivity.class); myIntent.putExtra(“name”, “Hong gil-dong”); myIntent.putExtra(“age”, 30); startActivity(intent);   // 받는 쪽 Intent intent = getIntent(); Bundle extras = getIntent().getExtras(); String name = extras.getString(“name”); String name = extras.getInt(“age”); or String name = getIntent().getStringExtra(“name”); int age = getIntent().getStringExtra(“age”);   // 키가 있는지 검사 if (intent.hasExtra(“name”)) { }    

Read More
Android

Notification

    public void ShowNotification() { NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); // 채널을 생성하고 시스템에 등록 (오레오 API 26 이상부터는 채널 필요) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = “My Channel 1”; String description = “My Channel 1 Description”; int importance = NotificationManager.IMPORTANCE_HIGH; // HIGH 옵션은 팝업 표시됨 NotificationChannel channel = new NotificationChannel(“12345”, name, importance); // 12345는 채널 ID channel.setDescription(description); notificationManager.createNotificationChannel(channel); // 채널을 시스템에 등록 } // 알림 생성 NotificationCompat.Builder builder = new NotificationCompat.Builder(this, “12345”) // 12345는 채널 ID .setSmallIcon(R.drawable.ic_launcher_background) .setContentTitle(“My notification”) .setContentText(“Much longer text that cannot fit one line…”)…

Read More