当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Save Message to the Inbox in Android?

问题描述:

I sending message using SMSManager, I can able to send the message but I want to save it in a message conversation (Default Message Application in Device)?

What i did is

ContentValues values = new ContentValues();

values.put("address", "123456789");

values.put("body", "foo bar");

getContentResolver().insert(Uri.parse("content://sms/sent"), values);

I can able to add it in the inbox but

As CommansWare comment from here,

The SMS content provider is not part of the Android SDK. Your code will break on devices that replace the SMS client with their own. Your code may break in future versions of Android

I dont have device to test in latest version, What will be the solution for all the version of android?

网友答案:

The content uri is not part of Android sdk. Although I haven't seen any devices that use alternative uri for sms provider, but it could be one. I think there is tiny possibility that Google will change this uri string to another one in the future. But vendor can also modify this. So generally there are no silver bullet for all the versions of Android.

As PLB said, you can add some updating and bug reporting feature to your application. When device updates to a version that has different provider, notify user about it and if you create new app that handles changes ask your customer to download one. And if your code fail to read/write the current uri. Report some information about the device to you. So you will be able to fix it up.

I first thought that maybe you can automatically look up the bytecode(dex bytecode) of the com.android.providers.telephony.SmsProvider. However, this is not part of Android sdk too.

分享给朋友:
您可能感兴趣的文章:
随机阅读: