오늘 한 일
- Rust공부
- Flutter FCM 연결구현
- Kotlin 약알림 앱
Rust 5.2, 예제코드
5.2 Struct 디버깅하기
예제코드 - 도형측량
fn main(){
let triangle1 = Triangle{
base_line: 12.0,
height: 6.0
};
let square1 = Square{
width: 4.0,
height: 8.0
};
let circle1 = Circle{
radius: 7.0
};
println!("{:?}", triangle1.area());
println!("{:?}", square1.length());
println!("{:?}", circle1.area());
}
trait Shape{
fn area(&self) -> f64;
fn length(&self) -> f64;
}
struct Triangle{
base_line: f64,
height: f64
}
impl Shape for Triangle{
fn area(&self)->f64{
self.base_line * self.height / 2.0
}
fn length(&self) -> f64{
println!("unknown!");
0.0
}
}
struct Square{
width: f64,
height: f64
}
impl Shape for Square{
fn area(&self)->f64{
self.width * self.height
}
fn length(&self) -> f64{
(self.width + self.height) *2.0
}
}
struct Circle{
radius: f64
}
impl Shape for Circle{
fn area(&self)->f64{
self.radius * self.radius * 3.14
}
fn length(&self) -> f64{
2.0 *self.radius*3.14
}
}
Flutter FCM 구현..
디바이스 토큰 변경
: 실제 기기의 디바이스 토큰이 아닌 firebase에서 할당하는 디바이스토큰을 반환하게 코드를 수정했다.
푸시알림이 안떠서 명시하지 않은 부분이 있나 검토중이다
블로그대로 따라했는데 알림이 안오는 이유는 firebase 연동 자체가 제대로 안돼서인걸까?
Koltin 이슈들
AndroidManifest 파일 액티비티 명시
: 앱을 켰을 때 처음으로 실행할 페이지를 명시하려면?
AndroidManifest.xml
파일에 Activity의 특성명시
<activity
android:name=".MainActivity"
... >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
...
</activity>
Activity 등록 기준
- Main/Launcher
- 다른 앱에서 접근가능한
- 다른 Activity에 의해 navigate 되는
- 권한/제한을 가진 경우
다른 Activity에 의해 navigate 되는 Activity 특성
- Launch mode: Defines how the activity is launched and how it integrates with the existing task stack. Launch modes include standard, singleTop, singleTask, and singleInstance.
- Task affinity: Specifies the task that the activity belongs to. Activities with the same task affinity can be launched together in the same task stack.
- Parent activity: Specifies the parent activity of the current activity. This helps in defining the navigation hierarchy and allows the Up button or navigation drawer to navigate up to the parent activity.
- Intent filters: Defines intent filters for the activity, allowing it to respond to specific intents and handle deep linking or explicit intents from other components.
Task Stack?
나중에 공부하자..
https://developer.android.com/guide/components/activities/tasks-and-back-stack?hl=ko
Default 액션바 없애기
: theme으로 설정되어있으므로 나타난다.
res/theme
에서 style을 수정할 수 있다.
⇒ <style name="Theme.___" parent="Theme.___.___.NoActionBar">
버튼 누르면 Navigating
:버튼을 누르면 (로그인 폼을 확인한 후) 다음 화면으로 이동하도록 설정한다.
1. 버튼을 Kotlin 코드에서 다뤄야함
리소스의 레이아웃 파일에 정의해놓은 버튼 찾기
val button: Button = findViewById(R.id.google_login)
참고로 위에서 findViewById
는 setContentView
이후에 쓰여야한다.
버튼에 Listener(이벤트핸들러)를 설정
googleLogin.setOnClickListener{
navController.navigate(R.id.login_page2)
}
2. compose 사용을 안할 때, Intent Object 사용
Intent
: 액티비티간 상호작용을 도와주는 시스템 오브젝트
//이 액티비티와, LoginActivity2라는 액티비티의 관계를 의미한다.
Intent(this, LoginActivity2::class.java)
startActivity(intent)
→ task 스택에 관계유지
마무리
1__ 2학기 시간표를 정했다
0순위
소프트웨어공학, 임베디드시스템설계, 데이터통신
1순위
인공지능, 투자론, 수학2
2순위
영화를활용한생각의기술