修复 app.sendEmail()出现“没有可以执行此动作的应用”的问题

This commit is contained in:
hyb1996 2018-10-16 23:06:44 +08:00
parent 72d46a3842
commit bae65152b8
2 changed files with 17 additions and 9 deletions

View File

@ -65,7 +65,7 @@ module.exports = function(runtime, global){
app.sendEmail = function(options){
options = options || {};
var i = new Intent(Intent.ACTION_SENDTO);
var i = new Intent(Intent.ACTION_SEND);
if(options.email){
i.putExtra(Intent.EXTRA_EMAIL, toArray(options.email));
}
@ -84,21 +84,26 @@ module.exports = function(runtime, global){
if(options.attachment){
i.putExtra(Intent.EXTRA_STREAM, android.content.Uri.parse("file://" + options.attachment));
}
i.setType("message/rfc822");
context.startActivity(Intent.createChooser(i, "发送邮件").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
function toArray(arg){
if(typeof(arg) == 'string'){
arg = [arg];
}
let arr = util.java.array("string", arg.length);
for(let i = 0; i < arg.length; i++){
arr[i] = arg;
}
return arr;
}
app.getUriForFile = function(file){
return android.support.v4.content.FileProvider.getUriForFile(context,
"org.autojs.autojs.fileprovider", new java.io.File(files.path(path)));
};
function toArray(arg){
if(typeof(arg) == 'string'){
return [arg];
}
return arg;
}
app.launch = app.launchPackage;
app.versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;

View File

@ -8,15 +8,18 @@ function typeToClass(type) {
if (typeof(type) != 'string') {
return type;
}
if(type == 'string'){
return java.lang.String;
}
var types = {
"int": "Integer",
"long": "Long",
"string": "String",
"double": "Double",
"char": "Character",
"byte": "Byte",
"float": "Float"
};
if (types[type]) {
return Packages["java.lang." + types[type]].TYPE;
}