在这篇文章中,我们将为您详细介绍ANDROID:android-parse中的电子邮件客户端接收者电子邮件ID为空的内容,并且讨论关于android邮件客户端的相关问题。此外,我们还会涉及一些关于an
在这篇文章中,我们将为您详细介绍ANDROID:android-parse中的电子邮件客户端接收者电子邮件ID为空的内容,并且讨论关于android 邮件客户端的相关问题。此外,我们还会涉及一些关于android – 从内部存储发送包含附件的电子邮件、android – 从联系人处获取电子邮件,ID和电话(不使用活动)、android – 使用Asset文件夹中的附件发送电子邮件、android – 发送带附件的电子邮件时出错的知识,以帮助您更全面地了解这个主题。
本文目录一览:- ANDROID:android-parse中的电子邮件客户端接收者电子邮件ID为空(android 邮件客户端)
- android – 从内部存储发送包含附件的电子邮件
- android – 从联系人处获取电子邮件,ID和电话(不使用活动)
- android – 使用Asset文件夹中的附件发送电子邮件
- android – 发送带附件的电子邮件时出错
ANDROID:android-parse中的电子邮件客户端接收者电子邮件ID为空(android 邮件客户端)
我在应用程序中使用了android-parse服务器。下面是解析email列的db屏幕截图。电子邮件列在数据库中隐藏密码列之后。
我的问题是
当我将电子邮件ID检索到电子邮件客户端时,即使电子邮件列中包含电子邮件,电子邮件也为null 。
注意:在另一个地方(另一个表)的应用程序中,我以相同的方式将电子邮件ID拉到电子邮件客户端,但是邮件显示得很好..仅在这里出现问题。
如果有人知道请帮忙吗?
这是解析数据库中的电子邮件列
try{ JSONObject jsonObject = parseObjectToJson(object); Log.d("Object", jsonObject.toString()); Log.d("Email", "+" + object.get("email")); personNumber = jsonObject.getString("telephone"); personEmail = jsonObject.getString("email"); }catch (JSONException je){ }catch (ParseException pe){ }
this is email button
emailPerson = (Button)findViewById(R.id.individualEmail); emailPerson.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_SEND); i.setData(Uri.parse("mailto:")); i.setType("plain/text"); i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {personEmail}); startActivity(i); } }); if(personEmail==null || personEmail.equals("") || personEmail.equals(" ")){ emailPerson.setClickable(false); emailPerson.setEnabled(false); emailPerson.setVisibility(View.GONE); } else{ emailPerson.setEnabled(true); emailPerson.setClickable(true); emailPerson.setVisibility(View.VISIBLE); }
here it is working fine but this is a different table in same database . >in
this table there is no hidden password field
try{ corporateEmail = jsonObject.getString("email"); if(corporateEmail == null || corporateEmail.equals("")){ emailCorporate.setVisibility(View.GONE); emailCorporate.setEnabled(false); emailCorporate.setClickable(false); }
emailCorporate = (Button) findViewById(R.id.corporateEmail); emailCorporate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_SEND); i.setData(Uri.parse("mailto:")); i.setType("plain/text"); i.putExtra(Intent.EXTRA_EMAIL, new String[] {corporateEmail}); startActivity(i); } });
private JSONObject parseObjectToJson(ParseObject parseObject) throws ParseException, JSONException, com.parse.ParseException { JSONObject jsonObject = new JSONObject(); parseObject.fetchIfNeeded(); Set<String> keys = parseObject.keySet(); for (String key : keys) { Object objectValue = parseObject.get(key); if (objectValue instanceof ParseObject) { jsonObject.put(key, parseObjectToJson(parseObject.getParseObject(key))); } else if (objectValue instanceof ParseRelation) { } else { jsonObject.put(key, objectValue.toString()); } } return jsonObject; }
答案1
小编典典如果jsonObject
不为null,请检查您从中提取数据的解析数据库是否具有“ email”标
android – 从内部存储发送包含附件的电子邮件
任何人都知道如何解决它或一个工作的例子?将外部存储上的所有东西都转换成是很糟糕的.
谢谢
Ps:我检查了其他线程,他们似乎没有解决方案(旧线程)
解决方法
I’m assuming you are trying to send the file as an email attachment
using intents.The reason why the file is empty is that the email app does not have
access to the file in /data/data/package_name/myfile_name,due to
Androids security model (the /data/data/package_name directory is
private to your app).In order to add the file as an attachment,you need to write it to public storage (such as the SD card) so the email app can access it.
android – 从联系人处获取电子邮件,ID和电话(不使用活动)
我的类没有扩展Activity或onCreate()方法.因此,从将扩展Activity的类传递给此类的context参数:
public static void getContactNumbers(Context context) {
String contactNumber = null;
int contactNumberType = Phone.TYPE_MOBILE;
String nameOfContact = null;
ContentResolver cr = context.getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
null, null, null);
if (cur.getCount() > 0) {
while (cur.movetoNext()) {
String id = cur.getString(cur
.getColumnIndex(BaseColumns._ID));
nameOfContact = cur
.getString(cur
.getColumnIndex(ContactsContract.Contacts.disPLAY_NAME));
if (Integer
.parseInt(cur.getString(cur
.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
Cursor phones = cr
.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID
+ " = ?", new String[] { id },
null);
while (phones.movetoNext()) {
contactNumber = phones.getString(phones
.getColumnIndex(Phone.NUMBER));
contactNumberType = phones.getInt(phones
.getColumnIndex(Phone.TYPE));
Log.i(TAG, "...Contact Name ...." + nameOfContact
+ "...contact Number..." + contactNumber);
ApplicationConstants.phoneContacts
.add(new ContactNumberBean(nameOfContact,
contactNumber, contactNumberType));
}
phones.close();
}
}
}// end of contact name cursor
cur.close();
}
如何实现ApplicationConstants和ContactNumberBean(nameOfContact,contactNumber,contactNumberType))这两个类?
解决方法:
这是几乎相同问题的解决方案 – Answer
希望能帮助到你 :)
android – 使用Asset文件夹中的附件发送电子邮件
//EMAIL SENDING CODE FROM ASSET FOLDER
email = editTextEmail.getText().toString();
subject = editTextSubject.getText().toString();
message = editTextMessage.getText().toString();
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("file/html");
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://com.example.deepa.xmlparsing/file:///android_assets/Combination-1.html"));
startActivity(Intent.createChooser(emailIntent, "Send email using"));
最后,我从资产文件夹(Combination-1.html)获取文件.
它越来越好了
Runtime error file not found exception.
有没有其他方式发送文件附件?
解决方法:
创建资产文件夹文件的File对象,并将此对象附加到您的电子邮件Intent.
并且如您的问题运行时错误文件中未提及异常所述,这可能是因为URL“file:/// android_asset /”未指向特定目录,它仅由WebView用于寻址资产.拉了那个from
您可以将其作为输入流打开并将此InputStream转换为File
in = new BufferedReader(new InputStreamReader(activity.getAssets().open(myfile.pdf)));
在电子邮件中发送此文件对象如下.
Intent intent = new Intent(Intent.ACTION_SEND ,Uri.parse("mailto:"));
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Card Set ");
intent.putExtra(Intent.EXTRA_TEXT, "");
intent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(file));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
Intent.ACTION_SEND用于通过电子邮件发送电子邮件附件的Intent.EXTRA_STREAM.您可以使用intent.setAction(Intent.ACTION_SEND_MULTIPLE);来引用多个Intent.EXTRA_STREAMin单一意图来引用多个附件.
intent.setType(String mimeType)输入参数表示您希望从触发意图(此处为intent实例)获得的MIME类型数据.where setype可以是
image/jpeg
audio/mpeg4-generic
text/html
audio/mpeg
audio/aac
audio/wav
audio/ogg
audio/midi
audio/x-ms-wma
video/mp4
video/x-msvideo
video/x-ms-wmv
image/png
image/jpeg
image/gif
.xml ->text/xml
.txt -> text/plain
.cfg -> text/plain
.csv -> text/plain
.conf -> text/plain
.rc -> text/plain
.htm -> text/html
.html -> text/html
.pdf -> application/pdf
.apk -> application/vnd.android.package-archive
android – 发送带附件的电子邮件时出错
码:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Halosys Greetings"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,""); emailIntent.putExtra(Intent.EXTRA_STREAM,bm); emailIntent.setType("image/png"); startActivity(Intent.createChooser(emailIntent,"Send mail..."));
错误堆栈:
12-28 11:42:37.456: ERROR/AndroidRuntime(21930): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.gm/com.google.android.gm.ComposeActivity}: java.lang.NullPointerException 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2663) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at android.os.Handler.dispatchMessage(Handler.java:99) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at android.os.Looper.loop(Looper.java:123) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at android.app.ActivityThread.main(ActivityThread.java:4627) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at java.lang.reflect.Method.invokeNative(Native Method) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at java.lang.reflect.Method.invoke(Method.java:521) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at dalvik.system.NativeStart.main(Native Method) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): Caused by: java.lang.NullPointerException 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at com.google.android.gm.provider.Gmail$AttachmentOrigin.localFileExtras(Gmail.java:2194) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at com.google.android.gm.ComposeArea.addAttachment(ComposeArea.java:732) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at com.google.android.gm.ComposeArea.initFromExtras(ComposeArea.java:685) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at com.google.android.gm.ComposeActivity.initFromExtras(ComposeActivity.java:1482) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at com.google.android.gm.ComposeActivity.finishOnCreateAfteraccountSelected(ComposeActivity.java:1021) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at com.google.android.gm.ComposeActivity.onCreate(ComposeActivity.java:259) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2627) 12-28 11:42:37.456: ERROR/AndroidRuntime(21930): ... 11 more
提前致谢.
解决方法
public void doSendFile() { String fileName = "myFileName.txt"; String externalStorageDirectory = Environment .getExternalStorageDirectory().toString(); String myDir = externalStorageDirectory + "/myDir/"; // the file will be in myDir Uri uri = Uri.parse("file://" + myDir + fileName); Intent i = new Intent(Intent.ACTION_SEND); try { myFileHandle.close(); // you may want to be sure that the file is closed correctly } catch (IOException e) { // Todo Auto-generated catch block e.printstacktrace(); } i.setType("text/plain"); // as you can see I am sending a simple txt file here i.putExtra(Intent.EXTRA_EMAIL,new String[] { "sendTo@gmail.com" }); i.putExtra(Intent.EXTRA_SUBJECT,"the subject text"); i.putExtra(Intent.EXTRA_TEXT,"extra text body"); Log.i(getClass().getSimpleName(),"logFile=" + uri); i.putExtra(Intent.EXTRA_STREAM,uri); try { startActivity(Intent.createChooser(i,"Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getBaseContext(),"There are no email clients installed.",Toast.LENGTH_SHORT) .show(); } }
也确定你有
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
在您的清单中,您可以在外部存储中实际创建该文件.
附:我从未设法直接从内部存储发送文件.
关于ANDROID:android-parse中的电子邮件客户端接收者电子邮件ID为空和android 邮件客户端的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于android – 从内部存储发送包含附件的电子邮件、android – 从联系人处获取电子邮件,ID和电话(不使用活动)、android – 使用Asset文件夹中的附件发送电子邮件、android – 发送带附件的电子邮件时出错的相关知识,请在本站寻找。
本文标签: