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

  • Home
  • SEARCH
  • 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 8788167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:05:55+00:00 2026-06-13T22:05:55+00:00

My application has the following modules, To collect users CB location code. To save

  • 0

My application has the following modules,

  1. To collect users CB location code.
  2. To save that in a database of user’s choice, say for example my CB code is 465783 and I can save that as ‘College’ in my database.
  3. To provide alarm feature, in this module I can give a text input say I give it as ‘College’ and when the Cell Broadcast is updated if the value college matches alarm is given out.

Now, in my below code I’ve achieved first 2 modules and also the required database entries, databases search etc, I’m not able to read the updated CB location value.

public class Alarm extends MainActivity {

public String str;

public void onReceive(Context context, Intent intent) {
    //---get the CB message passed in---
    Bundle bundle = intent.getExtras();        
    SmsCbMessage[] msgs = null;
    str = "";            
    if (bundle != null)  {
        //---retrieve the SMS message received---
        Object[] pdus = (Object[]) bundle.get("pdus");
        msgs = new SmsCbMessage[pdus.length];            
        for (int i=0; i<msgs.length; i++) {
            msgs[i] = SmsCbMessage.createFromPdu((byte[])pdus[i]);                
            str += "CB " + msgs[i].getGeographicalScope() + msgs[i].getMessageCode() + msgs[i].getMessageIdentifier() + msgs[i].getUpdateNumber();                     
            str += " :";
            str += "\n";        
        }
        }
        }


EditText user_value;
Button startalarm;
Button stopalarm;


/** Called when the activity is first created. */
@Override
 public void onCreate(Bundle savedInstanceState) 
{
 super.onCreate(savedInstanceState);
 setContentView(R.layout.third);

 startalarm = (Button) findViewById(R.id.startalarm);
 stopalarm = (Button) findViewById(R.id.stopalarm);
user_value = (EditText) findViewById(R.id.user_value);

final Ringtone ringtone;
ringtone = RingtoneManager.getRingtone(getBaseContext(),     RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));

startalarm.setOnClickListener(new View.OnClickListener() 
{

public void onClick(View arg0)
{
        // TODO Auto-generated method stub
if(user_value.length()==0)
{
    Toast.makeText(getBaseContext(), "Please enter a value.", Toast.LENGTH_LONG).show();
}

    Toast.makeText(getApplicationContext(), "alarm set", Toast.LENGTH_LONG).show();

//I want my alarm event to be started from here whenever a new CB sms arrives.

SQLiteDatabase aa = openOrCreateDatabase("MLIdata", MODE_WORLD_READABLE, null);
    Cursor c = aa.rawQuery("SELECT CblocationName FROM MLITable WHERE CblocationCode = '"+str+"'", null);
    c.moveToFirst();
    c.getString(c.getColumnIndex("CblocationName"));
    String sas = user_value.getText().toString();
    if(sas.equals(c.getString(c.getColumnIndex("CblocationName"))))
    {
        //here comes the alarm code


        if(ringtone == null)
        {
            Log.d("Debug", "ringtone is null");
        }
        else
        {
            ringtone.play();

        }
    }
}


});

stopalarm.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
    // TODO Auto-generated method stub
    ringtone.stop();
}
});
}
}

Detailed Explanation : whenever a user enters a new tower location he gets the updated Cell Broadcast message from the tower, so when this cbsms arrives I need to start my event of retrieving the CB area code and compare it with my database of area codes (which obviously have corresponding area code names set by the user) and when there is a match between the user given area name’s corresponding area code with my current area code an alarm needs to be started, here I’m not able to do detect the arrival of updated location.

If further explanation is required of my problem statement, please comment.

From the comments received below, I’ve deduced that I’d need a receiver class, I’ve created one for my widget which does the same function (Displays the Cb location code on the widget), Now I do not how to activate that in my app.

My WidgetReceiver.java

public class CbReceiver extends BroadcastReceiver
    {


        public void onReceive(Context context, Intent intent) {
            //---get the CB message passed in---
            Bundle bundle = intent.getExtras();        
            SmsCbMessage[] msgs = null;
            String str = "";            
            if (bundle != null)  {
                //---retrieve the SMS message received---
                Object[] pdus = (Object[]) bundle.get("pdus");
                msgs = new SmsCbMessage[pdus.length];            
                for (int i=0; i<msgs.length; i++) {
                    msgs[i] = SmsCbMessage.createFromPdu((byte[])pdus[i]);                
                    str += "CB " + msgs[i].getGeographicalScope() + msgs[i].getMessageCode() + msgs[i].getMessageIdentifier() + msgs[i].getUpdateNumber();                     
                    str += " :";
                    str += msgs[i].getMessageBody().toString();
                    str += "\n";       

                abortBroadcast();
                Toast.makeText(context, str, Toast.LENGTH_LONG).show();

                    AppWidgetManager appWidgetManager =     AppWidgetManager.getInstance(context);
            RemoteViews remoteViews = new RemoteViews(context.getPackageName(),R.layout.widget);
            ComponentName thisWidget = new ComponentName(context,MyWidget.class);
            remoteViews.setTextViewText(R.id.update,str);
            appWidgetManager.updateAppWidget(thisWidget, remoteViews);

        }                         
    }}
}

Help required.

Thank you.

  • 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-06-13T22:05:56+00:00Added an answer on June 13, 2026 at 10:05 pm
    1. Start your activity from your receiver on tower change. Use Intents to start your activity from receivers.
      Ex: Refer this alarm example for above point, Alarm Example

    2. Register your receiver in Android Manifest.xml.

    3. Send a broadcast message from your receiver class also update your DB inside your receiver.
    4. Catch the same in your activity. You can use Custom Broadcast for this.
    5. Now activate your alarm in activity.

    Hope these steps will help you. Refer the example I have mentioned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a Zend application that has these following modules: Users Shop etc... Front
I'm creating an application that collects users location (Cell broadcast location code) and saves
So we have a PHP+Zend Framework+Doctrine 1.2 application that has the following structure: Controller
I am attempting to run an application in IIS8 that has the following in
We have a multi module project with following modules: Database Persistence Business Application The
I am actually developing and application that has around 15 modules, all of them
My Application has the following structure: myproject (primary Silverlight project) myproject.Web (website for the
My application has the following patterns: a FrontController, Command, Service, and DAO. The problem
My android application has several warnings of the following form when I run it
We have the following setting: There is a web application which has a jboss

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.