File size: 2,020 Bytes
d517dc9 | 1 2 3 4 5 | {"type": "session", "harness": "deepseek-harness", "id": "mc-0031", "name": "Android Kotlin basics"}
{"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}}
{"type": "message", "message": {"role": "user", "content": "How do I create an Android app with Kotlin?"}}
{"type": "message", "message": {"role": "assistant", "content": "```kotlin\n// MainActivity.kt\nclass MainActivity : AppCompatActivity() {\n private lateinit var binding: ActivityMainBinding\n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n binding = ActivityMainBinding.inflate(layoutInflater)\n setContentView(binding.root)\n\n binding.button.setOnClickListener {\n val name = binding.editText.text.toString()\n binding.textView.text = \"Hello, $name!\"\n }\n }\n}\n\n// ViewModel\nclass MainViewModel : ViewModel() {\n private val _uiState = MutableStateFlow(UiState())\n val uiState: StateFlow<UiState> = _uiState.asStateFlow()\n\n fun loadData() {\n viewModelScope.launch {\n _uiState.value = _uiState.value.copy(loading = true)\n val data = repository.getData()\n _uiState.value = UiState(data = data, loading = false)\n }\n }\n}\n\n// Room database\n@Entity\ndata class User(@PrimaryKey val id: Int, val name: String, val email: String)\n\n@Dao\ninterface UserDao {\n @Query(\"SELECT * FROM users\")\n fun getAll(): Flow<List<User>>\n\n @Insert\n suspend fun insert(user: User)\n}\n\n@Database(entities = [User::class], version = 1)\nabstract class AppDatabase : RoomDatabase()\n```"}}
|