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 5848377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:51:01+00:00 2026-05-22T12:51:01+00:00

Send Text Messages (SMS) From Android When Near A Predefined Location… Ex. i enter

  • 0

Send Text Messages (SMS) From Android When Near A Predefined Location…

Ex. i enter in the college or out from the college that time my Android device check my current position if it match with predefine position then my device send automatic sms to other no.

Any buddy have idea or code related to this ..

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-05-22T12:51:02+00:00Added an answer on May 22, 2026 at 12:51 pm

    I put whole code from my SMS util. You should have a look at sendSms function. The util allows you to watch for incoming sms and track sms sent by you ( If you want to do that ).

    The next part is to handle location updates. The best way how to do it depends on many things. You can obtain location via LocatinProviders ( GPS, wireless or passive ) or read cell info from TelephonyManager. Below you have some details about them:

    1. LocationProvider:

      • returns geo lat/lon data
      • you can not read data if user disabled “Use GPS satellites” and “User wireless networks”
      • you will rather not get data if you are in a building ( no GPS signal there ).
      • you have to wait very long for the location.
      • very good accuracy.
      • can drain battery a lot.
      • “pasive” provider can be a good choice for you.
    2. Cells.

      • returns the neighboring cell information of the device.
      • location is not available if your device is not connected to gsm/cdma network ( no sim card ).
      • not good accuracy but rather for you purpose will be ok.
      • doesn’t kill battery so much.

    Which option is better for you ?

       package android.commons;
    
        import java.util.ArrayList;
        import java.util.HashMap;
        import java.util.Map;
    
        import android.app.Activity;
        import android.app.PendingIntent;
        import android.content.BroadcastReceiver;
        import android.content.ContentValues;
        import android.content.Context;
        import android.content.Intent;
        import android.content.IntentFilter;
        import android.net.Uri;
        import android.os.Bundle;
        import android.telephony.gsm.SmsManager;
        import android.telephony.gsm.SmsMessage;
        import android.util.Log;
    
        public final class SmsModem extends BroadcastReceiver {
    
                private static final String SMS_DELIVER_REPORT_ACTION = "android.commons.SMS_DELIVER_REPORT";
                private static final String SMS_DELIVER_REPORT_TOKEN_EXTRA = "token";
    
                private static final String TAG = SmsModem.class.getSimpleName();
                private final Context context;
                private final SmsManager smsManager;
                private final SmsModemListener listener;
    
                private final Map<String, Integer> pendingSMS = new HashMap<String, Integer>();
    
                public interface SmsModemListener {
                        public void onSMSSent(String token);
                        public void onSMSSendError(String token, String errorDetails);
                        public void onNewSMS(String address, String message);
                }
    
                public SmsModem(Context c, SmsModemListener l) {
                        context = c;
                        listener = l;
                        smsManager = SmsManager.getDefault();
                        final IntentFilter filter = new IntentFilter();
                        filter.addAction(SMS_DELIVER_REPORT_ACTION);
                        filter.addAction("android.provider.Telephony.SMS_RECEIVED");
                        context.registerReceiver(this, filter);         
                }
    
                public void sendSms(String address, String message, String token) {             
                        if ( message != null && address != null && token != null) {
                                final ArrayList<String> parts = smsManager.divideMessage(message);                      
                                final Intent intent = new Intent(SMS_DELIVER_REPORT_ACTION);
                                intent.putExtra(SMS_DELIVER_REPORT_TOKEN_EXTRA, token);                                         
                                final PendingIntent sentIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
                                final ArrayList<PendingIntent> intents = new ArrayList<PendingIntent>();
                                for ( int i = 0 ; i < parts.size() ; i++ ) {
                                        intents.add(sentIntent);
                                }
                                pendingSMS.put(token, parts.size());
                                smsManager.sendMultipartTextMessage(address, null, parts, intents, null);
                        }       
                }
    
                public void clear() {
                        context.unregisterReceiver(this);
                }
    
                @Override
                public void onReceive(Context c, Intent intent) {
                        final String action = intent.getAction();
                        if ( action.equalsIgnoreCase("android.provider.Telephony.SMS_RECEIVED")) {
                                final Bundle bundle = intent.getExtras(); 
                    if (bundle != null) { 
                            Object[] pdusObj = (Object[]) bundle.get("pdus"); 
                            final SmsMessage[] messages = new SmsMessage[pdusObj.length]; 
                            for (int i = 0; i<pdusObj.length; i++) { 
                                messages[i] = SmsMessage.createFromPdu ((byte[]) pdusObj[i]);
                                final String address = messages[i].getDisplayOriginatingAddress();
                                final String message = messages[i].getDisplayMessageBody();
                                listener.onNewSMS(address, message);
                            } 
                        }
                        } else if ( action.equalsIgnoreCase(SMS_DELIVER_REPORT_ACTION)) {
                                final int resultCode = getResultCode();
                                final String token = intent.getStringExtra(SMS_DELIVER_REPORT_TOKEN_EXTRA);
                                Log.d(TAG, "Deliver report, result code '" + resultCode + "', token '" + token + "'");
                                if ( resultCode == Activity.RESULT_OK ) {
                                        if ( pendingSMS.containsKey(token) ) {
                                                pendingSMS.put(token, pendingSMS.get(token).intValue() - 1);
                                                if ( pendingSMS.get(token).intValue() == 0 ) {
                                                        pendingSMS.remove(token);
                                                        listener.onSMSSent(token);
                                                }
                                        }                               
                                } else {
                                        if ( pendingSMS.containsKey(token) ) {
                                                pendingSMS.remove(token);
                                                listener.onSMSSendError(token, extractError(resultCode, intent));                                       
                                        }
                                }
                        }
                }
    
                private String extractError(int resultCode, Intent i) {
                        switch ( resultCode ) {
                        case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                                if ( i.hasExtra("errorCode") ) {
                                        return i.getStringExtra("errorCode");
                                } else {
                                        return "Unknown error. No 'errorCode' field.";
                                }
                        case SmsManager.RESULT_ERROR_NO_SERVICE:
                                return "No service";                    
                        case SmsManager.RESULT_ERROR_RADIO_OFF:
                                return "Radio off";
                        case SmsManager.RESULT_ERROR_NULL_PDU:
                                return "PDU null";
                                default:
                                        return "really unknown error";
                        }
                }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi guys can i write a service in android that will send text messages?
I would like to develop a way for sending text messages (SMS) from Microsoft
I want easy way to send some text messages from iphone to facebook and
I am currently developing a web service that is configured to receive SMS text
I am developing a simple application which has to send an SMS message from
HI I am trying to send sms in android 1.5 by breaking it in
Im using a php wrapper to find all unread sms messages from my google
I'd like to make an app to send/receive text messages using a GSM modem.
I followed this tutorial : http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/ and I got the alert 'Text messaging is
how to send rich text message in system.net.mail need code for send a mail

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.