我有一个应用程序,我应该读取一个调用,然后自动发送一条消息给调用者。我以编程方式创建了消息,但我决定让用户在数据库中为自己创建消息。现在我将这条消息保存在数据库中,并可以使用烤面包片实际查看它。但问题是现在没有将消息作为消息发送。我认为问题是在通话期间从数据库加载数据。因此,我想问一下,如果有人知道一个线程我可以使用,使这项工作异步请帮我...Android SQLite和线程
下面是相关代码
NotificationsDatabaseAdapter simsHelper;
case TelephonyManager.CALL_STATE_RINGING:
final String S1 = "kingmaker";
String notificationText = simsHelper.getData(S1);
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(toPhoneNumber, null, notificationText,
null, null);
Toast.makeText(getApplicationContext(), "SMS sent.",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Sending SMS failed.",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}