有没有没有 SMS 内容提供商的 Android 手机?

发布于 2024-11-15 12:08:16 字数 336 浏览 2 评论 0原文

我正在编写一个应用程序,它需要读取用户的短信以进行基本操作。谷歌表示,SMS 内容提供商不受支持,并且可能不会出现在某些手机中,或者可能无法在未来版本的 Android 中运行。我想知道是否有人知道没有短信内容提供商的特定手机?我知道这个问题已经被问过 -

是有没有手机没有短信收件箱内容提供商?但没有人提供答案。 或者,如果有人可以建议一种使用标准 API 读取传入和传出消息的方法,那就更好了。

I'm writing an app which needs to read the user's text messages for it's basic operation. Google says, SMS content provider is not supported and may not be present in certain phones, or may not work in future versions of Android. I would like to know if anyone knows of any specific phones without the SMS content provider? I know the question has already been asked -

Is there any phone that doesn't have sms inbox content provider? but no one has provided an answer.
Alternatively, if someone could suggest a way of reading incoming and outgoing messages using a standard API, that would be even better.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟若柳尘 2024-11-22 12:08:16

我还没有找到一款没有短信内容提供商的手机(至少从谷歌搜索中是这样)。我认为制造商不会冒破坏与众多短信应用程序(它们都使用此私有 API)兼容性的风险。
此外,目前似乎还没有标准方法来访问传入和传出消息。

更新:这已成为 4.4 的公共 API - https://developer.android .com/reference/android/provider/Telephony.html

I haven't been able to find a phone without an SMS content provider (at least from Google searches). I don't think manufacturers would take the risk of breaking compatibility with the numerous SMS applications out there (which all use this private API).
Also, at this point there seems to be no standard way to access both incoming and outgoing messages.

Update: This has been made a public API with 4.4 - https://developer.android.com/reference/android/provider/Telephony.html

为你拒绝所有暧昧 2024-11-22 12:08:16
Uri mSmsinboxQueryUri = Uri.parse("content://sms");
Cursor cursor1 = getContentResolver().query(
        mSmsinboxQueryUri,
        new String[] { "_id", "thread_id", "address", "person", "date",
                "body", "type" }, null, null, null);
startManagingCursor(cursor1);
String[] columns = new String[] { "address", "person", "date", "body",
        "type" };
if (cursor1.getCount() > 0) {
    String count = Integer.toString(cursor1.getCount());
    Log.e("Count",count);
    while (cursor1.moveToNext()) {
        out.write("<message>");
        String address = cursor1.getString(cursor1
                .getColumnIndex(columns[0]));
        String name = cursor1.getString(cursor1
                .getColumnIndex(columns[1]));
        String date = cursor1.getString(cursor1
                .getColumnIndex(columns[2]));
        String msg = cursor1.getString(cursor1
                .getColumnIndex(columns[3]));
        String type = cursor1.getString(cursor1
                .getColumnIndex(columns[4]));
}
}

使用

Uri mSmsinboxQueryUri = Uri.parse("content://sms/inbox");
Uri mSmsinboxQueryUri = Uri.parse("content://sms/sent");

此 uri,您可以阅读收件箱以及已发送的项目。

而manifest文件中的用户权限是

<uses-permission android:name="android.permission.READ_SMS" />
Uri mSmsinboxQueryUri = Uri.parse("content://sms");
Cursor cursor1 = getContentResolver().query(
        mSmsinboxQueryUri,
        new String[] { "_id", "thread_id", "address", "person", "date",
                "body", "type" }, null, null, null);
startManagingCursor(cursor1);
String[] columns = new String[] { "address", "person", "date", "body",
        "type" };
if (cursor1.getCount() > 0) {
    String count = Integer.toString(cursor1.getCount());
    Log.e("Count",count);
    while (cursor1.moveToNext()) {
        out.write("<message>");
        String address = cursor1.getString(cursor1
                .getColumnIndex(columns[0]));
        String name = cursor1.getString(cursor1
                .getColumnIndex(columns[1]));
        String date = cursor1.getString(cursor1
                .getColumnIndex(columns[2]));
        String msg = cursor1.getString(cursor1
                .getColumnIndex(columns[3]));
        String type = cursor1.getString(cursor1
                .getColumnIndex(columns[4]));
}
}

and

Uri mSmsinboxQueryUri = Uri.parse("content://sms/inbox");
Uri mSmsinboxQueryUri = Uri.parse("content://sms/sent");

Use this uri u can read inbox as well as the sent items.

And the user permission in the manifest file is

<uses-permission android:name="android.permission.READ_SMS" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文