当用户尝试使用whatsapp共享图像时,我一直在尝试构建一个显示为可选图像源的应用程序.到目前为止,我已经设法让我的应用程序显示在服务选择器中whatsapp使用intent过滤器启动但我无法让图像正确返回到whatsapp.我在下面发布我的代码:
public void returnImage(View v){
//Bitmap img;
//Bundle selectedImage = new Bundle();
Uri imageURI;
Intent shareIntent = new Intent();
switch(v.getId()){
case R.id.eric1 :
imageURI = saveToCache(R.drawable.cartman1);
shareIntent.putExtra(Intent.EXTRA_STREAM, imageURI);
shareIntent.setType("image/png");
setResult(RESULT_OK, shareIntent);
Utils.makeToast("Selected",this);
System.out.println("--------------------------------");
System.out.println(imageURI.toString());
finish();
}
}
private Uri saveToCache(int resID) {
// TODO Auto-generated method stub
Bitmap image = BitmapFactory.decodeResource(getResources(), resID);
File imageFile;
Date d = new Date();
String imgName = ((Long.toString(d.getTime())).subSequence(1,
9)).toString();
String state = Environment.getExternalStorageState();
printDebug(state);
if (Environment.MEDIA_MOUNTED.equals(state)) {
File file = getExternalFilesDir(null);
if (file != null) …Run Code Online (Sandbox Code Playgroud) Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://" + ContextID.getPackageName() + "/" + ResourceID));
share.setType("audio/*");
ContextID.startActivity(Intent.createChooser(share, "Condividi il suono"));
Run Code Online (Sandbox Code Playgroud)
以上代码适用于Gmail,而Whatsapp提供了"分享文件失败,请再试一次"的祝酒消息
也许我对这个人有同样的问题:Intent.ACTION_SEND Whatsapp
但是我如何暂时将我的资源复制到SD卡上然后分享呢?
是否可以在不打开应用程序的情况下发送whatsApp消息,在后台发送,如使用以下方式发送短信:
smsManager.sendTextMessage("+12546304580", null, "Test Message", null, null);
Run Code Online (Sandbox Code Playgroud)
如果是这样的话?我尝试的代码打开了APP(WITH INTENT):
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
String text = "Test Message";
waIntent.setPackage("com.whatsapp");
waIntent.putExtra(Intent.EXTRA_TEXT, text);//
startActivity(Intent.createChooser(waIntent, "Share with"));
Run Code Online (Sandbox Code Playgroud)
或者是否可以打开应用程序发送消息到给定地址并关闭它?
谢谢!
我有资产文件夹中的图像,需要与whatsapp应用程序共享
我试过这个代码,它一直让我分享失败再试一次!怎么了 ?!
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
share.setPackage("com.whatsapp");
// share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("file:///assets/epic/adv.png")));
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///assets/epic/adv.png"));
this.startActivity(Intent.createChooser(share, "share_via"));
Run Code Online (Sandbox Code Playgroud) 我在gifthub上找到了一个正是我想要的存储库.你能帮我解决一下如何使用单个按钮进行编码.我还没有足够的经验与ios programmin这样做.我几乎完成了我的第一个应用程序,但我需要帮助.
提前致谢
我正在尝试在chrome上发送whatsapp web版本的短信.(www.web.whatsapp.com)
这是代码:
document.getElementsByClassName("input")[1].innerHTML="This message was written via JS script! ";
var input = document.getElementsByClassName("icon btn-icon icon-send");
input[0].click();Run Code Online (Sandbox Code Playgroud)
但问题是,最初没有文本时输入框如下所示:

只有当我在物理上写一些文字时,它才会改为:

只有现在我的脚本才有效,因为它需要Send text button.
我尝试使用Jquery代码通过以下函数模拟$('.input)的按键:
function pressKey() {
var e = jQuery.Event("keypress");
e.which = 32; // # space
$(".input").trigger(e)[1];
e.which = 91;
$(".input").trigger(e)[1];
e.which = 32; // # space
$(".input").trigger(e)[1];
e.which = 32; // # space
$(".input").trigger(e)[1];
}Run Code Online (Sandbox Code Playgroud)
它没用.
如何Send text通过脚本获取按钮?
我正在从android获取联系人并将其存储在数据库中。在模拟器上对其进行了测试,并且可以正常工作。但是,当我在手机上测试该应用程序时,我得到了使用Whatsapp的联系人的重复条目。下面是代码片段。
class LoadContactAsync extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... params) {
Cursor people = getContentResolver()
.query(ContactsContract.Contacts.CONTENT_URI, null, null, null,
"UPPER(" + ContactsContract.Contacts.DISPLAY_NAME
+ ") ASC");
while (people.moveToNext()) {
final String contactId = people.getString(people
.getColumnIndex(ContactsContract.Contacts._ID));
final String contactName = people
.getString(people
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
final String image_uri = people
.getString(people
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI));
final String hasPhone = people
.getString(people
.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
if ((Integer.parseInt(hasPhone) > 0)) {
Cursor phones = getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId, null,
"UPPER(" + ContactsContract.Contacts.DISPLAY_NAME …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android应用程序,我需要向WhatsApp的特定联系人发送消息.我试过这段代码:
Uri mUri = Uri.parse("smsto:+999999999");
Intent mIntent = new Intent(Intent.ACTION_SENDTO, mUri);
mIntent.setPackage("com.whatsapp");
mIntent.putExtra("sms_body", "The text goes here");
mIntent.putExtra("chat",true);
startActivity(mIntent);
Run Code Online (Sandbox Code Playgroud)
问题是虽然选择了联系人,但WhatsApp上没有收到参数"sms_body".
我正在尝试将whatsapp消息发送到存储在全局变量中的收件人号码!
通过使用这个简单的代码:
let whatsAppUrl = NSURL(string: "whatsapp:\(globalPhone)")
if UIApplication.shared.canOpenURL(whatsAppUrl as! URL) {
UIApplication.shared.openURL(whatsAppUrl as! URL)
}
else {
let errorAlert = UIAlertView(title: "Sorry", message: "You can't send a message to this number", delegate: self, cancelButtonTitle:"Ok")
errorAlert.show()
}
Run Code Online (Sandbox Code Playgroud)
我总是得到警告信息,这是其他情况!虽然数字总是如此!可能是url语法中的错误?
在控制台中:
canOpenURL: failed for URL: "whatsapp:0534260282" -
"This app is not allowed to query for scheme whatsapp"
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?或者这种方式只是为了分享,通过Whatsapp发短信?
我目前正在使用以下脚本从Google云端硬盘获取常规文件。它工作正常,基本上是来自用户@ user115202的代码。
现在,我需要将其用于Whatsapp备份,该备份存储在GoogleDrive的“备份”下,而不是常规文件。
该工具WhatsApp的Google Drive提取器(Google Drive API)似乎不再起作用。
有人知道替代品吗?
import requests
def download_file_from_google_drive(id, destination):
def get_confirm_token(response):
for key, value in response.cookies.items():
if key.startswith('download_warning'):
return value
return None
def save_response_content(response, destination):
CHUNK_SIZE = 32768
with open(destination, "wb") as f:
for chunk in response.iter_content(CHUNK_SIZE):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
URL = "https://docs.google.com/uc?export=download"
session = requests.Session()
response = session.get(URL, params = { 'id' : id }, stream = True)
token = get_confirm_token(response)
if token:
params = { 'id' : id, …Run Code Online (Sandbox Code Playgroud)