我刚刚建造了广播接收器,我可以拿到新文本的电文,而我是在有空间时将案文信息分开,将其保留到“条码”。
现在,我需要检查一下,在<代码>中,标准是我数据库中的内容。 为此,我设立了一个<代码>ArrayList<String>,从相应的栏目中获取所有条目。 现在,我需要检查一下,在我的<密码>中,“射线/代码”中的“强硬”是否与文本电文相同,但我不知道如何认识到这一点。
是否有容易和快速的办法来检查,我还需要知道这两者中有哪些优势?
<>SmileySmsReceiver:
package de.retowaelchli.filterit.services;
import java.util.ArrayList;
import de.retowaelchli.filterit.database.SFilterDBAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;
public class SmileySmsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
{
//Datenbank definieren
SFilterDBAdapter mDbHelper = new SFilterDBAdapter(context);
//---get the SMS message passed in---
Log.d("SmileySmsReceiver", "Yes it calls the onReceive");
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null)
{
Log.d("SmileySmsReceiver", "Bundle is not null");
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
str += "SMS from " + msgs[i].getOriginatingAddress();
str += " :";
str += msgs[i].getMessageBody().toString();
str += "
";
Log.d("SmileySmsReceiver","Was steht in der Nachricht?: " + str);
String[] splited = str.split("\s+");
//Hier werden die Strings der Smileys aus der Datenbank gezogen
mDbHelper.open();
Cursor c = mDbHelper.getAllSFilter();
ArrayList<String> SmileyList = new ArrayList<String>();
c.getColumnIndex(SFilterDBAdapter.KEYWORD);
int ColumnIndex = c.getColumnIndex(SFilterDBAdapter.KEYWORD);
if(c!=null)
{
//Hier werden die Smileys in die ArrayList geschrieben
while(c.moveToNext()){
String infoItem = c.getString( ColumnIndex );
SmileyList.add(infoItem);
}
<------------------------- FROM HERE ON I NEED YOUR GUYS HELP ------------------------------->
}
}
//---display the new SMS message---
Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
}
}
}