java - 如何在 Gradle 中打开带有主题和正文的默认邮件程序?

标签 java android email gradle

我正在尝试创建一个 Gradle 任务,取决于 assembleRelease 任务。 它将根据生成的release-APK路径准备一封邮件,并在默认邮件程序中打开它。

我搜索了很多相关内容,发现 Java 的 Desktop-API 可以做到这一点。

但是当我尝试在 Gradle 脚本中使用它时,它给出以下错误:

Unable to resolve class Desktop

是否可以在 Gradle 脚本中创建这样的“邮件”任务?

最佳答案

通过在 gradle.properties 中指定属性来编写代码以打开电子邮件应用

通过下面的代码访问属性

Properties prop = new Properties();
InputStream input = null;

try {

    input = new FileInputStream("gradle.properties");

    // load a properties file
    prop.load(input);

    // get the property value and print it out
    System.out.println(prop.getProperty("user.password"));
} catch (IOException ex) {
    ex.printStackTrace();
}

看看这个 tutorial

关于java - 如何在 Gradle 中打开带有主题和正文的默认邮件程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43039321/

相关文章:

php mail onclick on link执行mysql命令

javascript - 是否有类似 Email Composer for Android 的 Phonegap 插件?

java - 使用 Jongo 和 Jackson 2,如何将 MongoDB ObjectId(在 POJO 中的 String _id 下表示)反序列化为十六进制 String 表示形式?

java - 带进度对话框的异步任务

Android 全屏应用程序 - 阻止访问状态栏

android - 应用程序 :srcCompat in xml 的 InflateException

php - 发送 PHP 电子邮件

java - 核心异常 : Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException

java - 使 Seekbar 遵循 MPAndroidChart X 值

java - 带有@PathVariable和@RequestParam的自定义 validator