feat: 增加kotlin支持,升级依赖到最新版

This commit is contained in:
2026-05-08 21:26:19 +08:00
parent 6baa7155ba
commit 59539d048d
3 changed files with 87 additions and 42 deletions

View File

@@ -0,0 +1,35 @@
package com.ttstd.dialer.utils
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.util.Log
class KotlinUtils {
companion object {
private const val TAG = "DialerUtils"
/**
* 拨打电话
* @param context 上下文
* @param phoneNumber 电话号码
*/
@JvmStatic
fun makeCall(context: Context, phoneNumber: String) {
try {
val intent = Intent(Intent.ACTION_CALL).apply {
data = Uri.parse("tel:$phoneNumber")
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
context.startActivity(intent)
Log.d(TAG, "正在拨打: $phoneNumber")
} catch (e: SecurityException) {
Log.e(TAG, "没有打电话权限", e)
} catch (e: Exception) {
Log.e(TAG, "拨打电话失败", e)
}
}
}
}