插入彩信发送到发件箱

编程入门 行业动态 更新时间:2024-10-21 07:50:48
本文介绍了插入彩信发送到发件箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图插入到彩信发送的数据库,但很可惜我一直没能在本土Android应用程序来查看它。

I'm trying to insert a MMS into the sent database but alas I haven't been able to view it in the native android application.

我插入code:

ContentValues values = new ContentValues(); values.put("thread_id", thread_id); values.put("date", time); values.put("read", true); //read status values.put("sub", text); //mms subject values.put("msg_box", 2); //message box. in this case outbox Uri mmsUri = context.getContentResolver(). insert(Uri.parse("content://mms"), values); Log.v("MMSProjectActivity", "Message saved at: " + mmsUri); ContentValues mmsPartValue = new ContentValues(); mmsPartValue.put("ct", "image/jpeg"); //mime; for example image/jpeg Uri picUri = picUris.get(0); String [] fileNameSplit = picUri.toString().split("/"); String fileName = fileNameSplit[fileNameSplit.length-1] + ".jpg"; String messageId = mmsUri.getLastPathSegment().trim(); //id of MMS at content://mms Uri partUri = Uri.parse("content://mms/" + messageId + "/part"); Uri mmsPartUri = context.getContentResolver().insert(partUri, mmsPartValue); OutputStream os; InputStream is; try { os = context.getContentResolver().openOutputStream(mmsPartUri); is = context.getContentResolver().openInputStream(picUris.get(0)); byte[] buffer = new byte[256]; for (int len = 0; (len = is.read(buffer)) != -1; ) { os.write(buffer, 0, len); } } catch (FileNotFoundException e) { Log.v("MMSProjectActivity", "MMS not saved FileNotFoundException"); e.printStackTrace(); } catch (IOException e) { Log.v("MMSProjectActivity", "MMS not saved IOException"); e.printStackTrace(); } Log.v("MMSProjectActivity", "MMS part value saved at: " + mmsPartUri);

任何人有任何想法我做错了?

anybody have any idea what am I doing wrong?

推荐答案

我想你需要的是在的来源$ C ​​$ C这个类。一般来看看他们是如何做到这一点在谷歌..在这种方法专门来看看

I think what you need is in this class of the source code . Generally take a look at how they do it at google.. specifically take a look at this method

private static Uri createDraftMmsMessage(PduPersister persister, SendReq sendReq, SlideshowModel slideshow) { try { PduBody pb = slideshow.toPduBody(); sendReq.setBody(pb); Uri res = persister.persist(sendReq, Mms.Draft.CONTENT_URI); slideshow.sync(pb); return res; } catch (MmsException e) { return null; } }

和创建草案(第一步),那么你更新草案发出后。通过调用其他方法

And after creating the Draft (step one) then you update the draft to sent. by calling the other method

private static void updateDraftMmsMessage(Uri uri, PduPersister persister, SlideshowModel slideshow, SendReq sendReq) { if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) { LogTag.debug("updateDraftMmsMessage uri=%s", uri); } if (uri == null) { Log.e(TAG, "updateDraftMmsMessage null uri"); return; } persister.updateHeaders(uri, sendReq); final PduBody pb = slideshow.toPduBody(); try { persister.updateParts(uri, pb); } catch (MmsException e) { Log.e(TAG, "updateDraftMmsMessage: cannot update message " + uri); } slideshow.sync(pb); }

现在我知道,因为你没有在源代码构建你不能从你的应用程序运行此code,或者即使你是它可能是这样做(尽管我认为,如果你建立一个挑战源,如果你code正确的谷歌code应处理好保存的东西)

Now I know you cannot run this code from your app since you're not building in the source, or even if you are it may be a challenge to do so (even though I think that if you do build in the source if you code correctly the google code should handle the save stuff)

在任何情况下,你应该能够按照他们在课堂上做什么的供应商,以节省彩信。

in any case you should be able to save mms message in the provider by following what they do in this class.

欢呼...

和发布你的进步...

and post your progress...

更多推荐

插入彩信发送到发件箱

本文发布于:2023-11-12 12:04:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581455.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送到   彩信   发件箱

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!