越来越"零"作为地址短信草案 [英] getting "null" as an address for a draft sms

查看:164
本文介绍了越来越"零"作为地址短信草案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想保存为草稿短信(TO)地址。我曾尝试在canonical_addresses表它给我留言查询无法找到canonical_addresses供应商信息,在日志中。
然后我尝试了它给我null作为一个地址短信/表草案查询。
什么是错误的,我code?我应该怎么传出去的短信草案的资料?我已搜查,但没有得到任何solution.Plz建议我一些解决方案。

I want to get (TO)address of sms saved as draft. I have tried query on canonical_addresses table it is giving me message "Failed to find provider info for canonical_addresses" in logs. Then I have tried query on sms/draft table it is giving me null as an address. What is wrong in my code? How should I get information about draft sms? I have searched but didn't get any solution.Plz suggest me some solution.

推荐答案

的方法是让的thread_id 对应于草稿邮件。查找使用,以解决的thread_id

The way is to get the thread_id that corresponds to the draft message. Find the to address by using thread_id

public String getPhoneNumbersFromThreadID(Context ctx, String threadId)
    {
        //System.out.println(threadId);
        String phoneList = "";
        ArrayList<String> phoneCheckList = new ArrayList<String>();

        if(thread2Phone.containsKey(threadId))
        {
            return thread2Phone.get(threadId);
        }
        if(threadId == null || threadId.equals(""))
        {
            return "No Name";
        }
        if(threadId.trim().length() == 0) return "No Name";


        Cursor c = ctx.getContentResolver().query(SMSMainListActivity.Sms_CONTENT_URI, 
                null, 
                "thread_id = '" + threadId + "'", null, "date ASC");
        if (c != null) {
            try {

                if (c.moveToFirst()) {


                    while (c.isAfterLast() == false) {
                        String num = c.getString(c
                                .getColumnIndex("address"));
                        num = num.replaceAll(";", ",");

                        String[] thisNum = num.split(",");
                        for (int i=0; i<thisNum.length; i++)
                        {
                            phoneCheckList.add(formatNumber(thisNum[i])) ;
                        }


                        c.moveToNext();
                    }


                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }finally
            {
                c.close();
            }
        }


        try {
            phoneCheckList = removeDuplicates(phoneCheckList);


            Iterator it = phoneCheckList.iterator();

            int i = 0;
            while (it.hasNext()) {
                String name = ""+it.next();
                //System.out.println("Iterated "+name);
                if(i==0)
                    phoneList = ""+name;
                else
                    phoneList += ";"+name;

                i++;
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        phoneCheckList.clear();
        thread2Phone.put(threadId, phoneList);
        return phoneList;
    }

这篇关于越来越&QUOT;零&QUOT;作为地址短信草案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆