修复 app.sendEmail()出现“没有可以执行此动作的应用”的问题
This commit is contained in:
@@ -65,7 +65,7 @@ module.exports = function(runtime, global){
|
|||||||
|
|
||||||
app.sendEmail = function(options){
|
app.sendEmail = function(options){
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var i = new Intent(Intent.ACTION_SENDTO);
|
var i = new Intent(Intent.ACTION_SEND);
|
||||||
if(options.email){
|
if(options.email){
|
||||||
i.putExtra(Intent.EXTRA_EMAIL, toArray(options.email));
|
i.putExtra(Intent.EXTRA_EMAIL, toArray(options.email));
|
||||||
}
|
}
|
||||||
@@ -84,21 +84,26 @@ module.exports = function(runtime, global){
|
|||||||
if(options.attachment){
|
if(options.attachment){
|
||||||
i.putExtra(Intent.EXTRA_STREAM, android.content.Uri.parse("file://" + 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));
|
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){
|
app.getUriForFile = function(file){
|
||||||
return android.support.v4.content.FileProvider.getUriForFile(context,
|
return android.support.v4.content.FileProvider.getUriForFile(context,
|
||||||
"org.autojs.autojs.fileprovider", new java.io.File(files.path(path)));
|
"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.launch = app.launchPackage;
|
||||||
|
|
||||||
app.versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
|
app.versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
|
||||||
|
|||||||
@@ -8,15 +8,18 @@ function typeToClass(type) {
|
|||||||
if (typeof(type) != 'string') {
|
if (typeof(type) != 'string') {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
if(type == 'string'){
|
||||||
|
return java.lang.String;
|
||||||
|
}
|
||||||
var types = {
|
var types = {
|
||||||
"int": "Integer",
|
"int": "Integer",
|
||||||
"long": "Long",
|
"long": "Long",
|
||||||
"string": "String",
|
|
||||||
"double": "Double",
|
"double": "Double",
|
||||||
"char": "Character",
|
"char": "Character",
|
||||||
"byte": "Byte",
|
"byte": "Byte",
|
||||||
"float": "Float"
|
"float": "Float"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (types[type]) {
|
if (types[type]) {
|
||||||
return Packages["java.lang." + types[type]].TYPE;
|
return Packages["java.lang." + types[type]].TYPE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user