【问题标题】:Android SMS Intent ProblemAndroid SMS 意图问题
【发布时间】:2011-07-10 20:10:03
【问题描述】:

我正在尝试使用从数据库中获取的短信正文打开系统短信应用程序。

我正在使用CursorSQLite 数据库中检索标题和消息。我有一个smsButton 将被点击。单击时,它将创建短信意图。

我的问题在于邮件的正文。我希望正文是从数据库中检索到的 msg_content。我试图引用它,但我相信我失败了。

这是我最后一次尝试,尝试使用一个 TextView 来获取 msg_content 布局的 id:

//First: DataBase Retrieving :
//fetch a msg from table `t` with id `id`
Cursor cursor = myDbHelper.fetchMessage(t, id); 
String[] columns = {cursor.getColumnName(1), cursor.getColumnName(2)}; 
int[] columnsLayouts = {R.id.title, R.id.msg_content}; //the columns styles
ca = new SimpleCursorAdapter(this.getBaseContext(), R.layout.msg_items_layout, cursor,columns , columnsLayouts);
lv = (ListView) findViewById(android.R.id.list); 
lv.setAdapter(ca);

//Here is MY PROBLEM :
TextView msgText = (TextView) findViewById(R.id.msg_content); //same Id as the msg_content column above
smsButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            String uri= "smsto:";
            Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
            intent.putExtra("sms_body", msgText.getText());
            intent.putExtra("compose_mode", true);
            startActivity(intent);
        }
    });

有什么方法可以引用内容的字符串?

【问题讨论】:

    标签: android sqlite sms android-listview android-cursor


    【解决方案1】:

    您正在调用findViewById() 活动...从数据库中取出数据?

    您应该使用您的Cursor 来获取您的信息。

    由于您没有费心提供实际的源代码(只是几个不连续的 sn-ps,AFAICT),因此很难给您具体的建议。对答案进行随机测试,我会删除smsButton,而是监听ListView 项目点击(例如,onListItemClick(),如果您正在实施ListActivity),然后使用提供的position 移动到在Cursor 的正确位置读出数据。

    【讨论】:

      猜你喜欢
      • 2010-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-28
      相关资源
      最近更新 更多