Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6727535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:03:39+00:00 2026-05-26T10:03:39+00:00

I just built a Broadcast Receiver with which I can get the incoming text

  • 0

I just built a Broadcast Receiver with which I can get the incoming text messages, than I split the text message when there’s a space and save it into a String[].

Now I need to check if in this String[] is something from my database. For that I created a ArrayList<String>, which gets all the entries from the corresponding column. Now I need to check if a String in my ArrayList is the same in my String[] from the text message, but I don’t know how to realize that.

Is there an easy and fast way to check that, also I need to know which String is in both of them?

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 += "\n";        
                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();
            }                         
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:03:39+00:00Added an answer on May 26, 2026 at 10:03 am

    If you have a String myString and an ArrayList<String> myListOfStrings, you can check if myString is in the list like this:

    myListOfStrings.contains( myString );
    

    This will return a boolean (true/false) – true if the strings was found, false if not.

    In your case you would want to run through the array of strings and match each of them to the SmileyList like this:

    for( String s : splitted ) {
       if( SmileyList.contains( s ) ) {
         //Do what you need to do if the string is in the SmileyList.
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just built a standard win32 applicaion but when I run it, there is
I am using Intel Fortran Composer XE. I just built a static library which
I have an html form which inserts data into a database. I just built
I am working on a Text-Based RPG for Android (just built around the default
I just built my program for MacOSX using GCC i.e. (gcc main.c). Are there
I just built an application in ASP.net that returns a PNG image. The resulting
I just built a WPF form that contains a ListBox. The ListBox has bound
I've just built a VS C++ 6.0 program using VS 2008. When I attempt
I've just built a basic ASP MVC web site for deployment on our intranet.
I have just built up my first SVN server, along with the mod_dav_svn module

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.