【问题标题】:how to i know in my application, when i sent new message?当我发送新消息时,我如何知道我的应用程序?
【发布时间】:2012-01-20 07:30:18
【问题描述】:

我正在开发一个与消息相关的应用程序。

在我的应用程序中,我通过使用 contentresolver 获取所有发送的消息。

代码是

c = getContentResolver().query(SMS_sent,null, null, null, null);

        startManagingCursor(c);
if(c!=null)
       {

        ((LinearLayout)findViewById(R.id.linearLayout11)).setVisibility(View.GONE); 

         String columns ="body";
             String columns1 = "address";

        SimpleCursorAdapter adapter2 = new SimpleCursorAdapter(this, R.layout.main2,c, 
                    new String[] {columns1,columns},  new int[]{R.id.textView2, R.id.textView4}); 
                    ListView empListView = (ListView)findViewById(R.id.listView1);
                    empListView.setAdapter(adapter2);
}

一切正常。

我的要求是当我发送新消息时,

我想在我的应用程序中处理它。

如果有人知道解决办法,请帮助我

提前致谢

【问题讨论】:

    标签: android


    【解决方案1】:

    您可能在谈论广播接收器。

    您可以为此目的制作广播接收器。

    关于消息的广播在andorid os中可用。

    尝试搜索。

    【讨论】:

    • Bu 使用 brodcast resevers 将获得有关接收短信的信息。但我想了解已发送的短信。
    • 对不起,我误会了。据我所知,没有办法。如果您制作了一个控制短信的应用程序。活动选择器将提示用户使用哪个应用程序。并且用户选择了您的应用程序,并且用户尝试发送新的短信,您的应用程序将被调用。
    【解决方案2】:

    您可以尝试在“content://sms/sent”ContentProvider 上注册一个 ContentObserver,但不能保证所有 SMS 应用程序都使用该 ContentProvider。

    Last sent SMS/text message: how to retrieve via ContentObserver?

    【讨论】:

      猜你喜欢
      • 2018-11-02
      • 1970-01-01
      • 2020-12-21
      • 2014-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-10
      • 2019-08-20
      相关资源
      最近更新 更多