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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:00:51+00:00 2026-05-24T02:00:51+00:00

I create a security application just like Mcafee wave secure. My application is listening

  • 0

I create a security application just like Mcafee wave secure.
My application is listening for SMS command and doing some action when the command is match, so I create a form with another service for listening the SMS.

Here’s the main form:

public static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
ArrayList<String> messageList;
ArrayAdapter< String> adapter;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //untuk mendisable notification area
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);
    MainButtonAbout=(Button) findViewById(R.id.MainbuttonAbout);
    MainButtonHelp=(Button) findViewById(R.id.MainbuttonHelp);
    MainButtonWizard=(Button) findViewById(R.id.MainbuttonWizard);
    MainButtonOption=(Button) findViewById(R.id.MainbuttonOption);
    MainCheckBoxActive=(CheckBox)findViewById(R.id.MaincheckBoxActive);

    MainButtonAbout.setOnClickListener(this);
    MainButtonHelp.setOnClickListener(this);
    MainButtonWizard.setOnClickListener(this);
    MainButtonOption.setOnClickListener(this);

    startService(new Intent(MainForm.this, ListenSMSservice.class));

    MainCheckBoxActive.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (buttonView.isChecked())
            {
                Toast.makeText(MainForm.this, "Your Device is Protected Now!!", 1).show();              
                startService(new Intent(MainForm.this, ListenSMSservice.class));
            }
            else
            {
                Toast.makeText(MainForm.this, "Your Device is not Protected Now!!", 1).show();
                stopService(new Intent(MainForm.this, ListenSMSservice.class));
            }
        }
    });

}

public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
    case R.id.MainbuttonAbout:
        Intent GoToAbout= new Intent(this,AboutForm.class);
        startActivity(GoToAbout);
        break;
    case R.id.MainbuttonHelp:
        Intent GoToHelp= new Intent(this,HelpForm.class);
        startActivity(GoToHelp);
        break;
    case R.id.MainbuttonWizard:
        Intent GoToWizard1= new Intent(this,WizardForm1.class);
        startActivity(GoToWizard1);
        break;
    case R.id.MainbuttonOption:
        Intent GoToOption= new Intent(this,OptionForm.class);
        startActivity(GoToOption);
        break;  
    default:
        break;
    }
}

and this is the Service form:

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public void onCreate() {
    Toast.makeText(this, "My Service Created", Toast.LENGTH_LONG).show();

}

/*@Override
public void onStart(Intent intent, int startid) {
    Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show();
    ListenSMS();
}*/

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    ListenSMS();
    // We want this service to continue running until it is explicitly
    // stopped, so return sticky.
    return START_STICKY;
}

private void ListenSMS() {
    // TODO Auto-generated method stub
    messageList  = new ArrayList<String>();
    adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, messageList);

    //Toast.makeText(this, "Masuk bagian sini sudah", 1).show();

    IntentFilter filter = new IntentFilter(SMS_RECEIVED);
    registerReceiver(receiver_SMS, filter);
}

BroadcastReceiver receiver_SMS = new BroadcastReceiver()
{
    public void onReceive(Context context, Intent intent)
    {
         if (intent.getAction().equals(SMS_RECEIVED))
         {
                Bundle bundle = intent.getExtras();
                if (bundle != null)
                {
                  Object[] pdus = (Object[]) bundle.get("pdus");
                  SmsMessage[] messages = new SmsMessage[pdus.length];

                  for (int i = 0; i < pdus.length; i++)
                    messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);

                  for (SmsMessage message : messages)
                  {
                         Toast.makeText(ListenSMSservice.this, "isi pesan >> "+message.getDisplayMessageBody(), Toast.LENGTH_LONG).show();
                         receivedMessage(message.getDisplayOriginatingAddress());
                         if (message.getDisplayMessageBody().toString().equalsIgnoreCase("aaaa"))
                         {
                             Toast.makeText(ListenSMSservice.this, "messegenya aaaa", 1).show();
                         }
                  }
                }
              }
    }
};
private void receivedMessage(String message)
{
    messageList.add(message);
    adapter.notifyDataSetChanged();
}

@Override
public void onDestroy() {
    Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG).show();
}

Unfortunately, my service can be stopped by Advanced task killer, so I can’t listen for the SMS command.

I’m using start_sticky option, but it does not work for me.
Does anyone have an idea how to handle that problem, so I can listen to the SMS (auto started service) even when task killer was used to kill my application?

  • 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-24T02:00:52+00:00Added an answer on May 24, 2026 at 2:00 am

    anyone have idea how to handle that problem, so i can listen to the SMS (auto started service) while task killer have killed my application

    If the user force-stops your application via Settings or a task killer, the user is saying that your app is not supposed to run. Please honor and respect that decision.

    As of Android 3.1, your application will not run again after being force-stopped, until the user launches it again from an activity.

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

Sidebar

Related Questions

I'm doing some research on security and sitemaps in ASP.net and am unfortunately running
Some of the guys here are developing an application which incorporates some 'secure areas'
I want to give my application data folder kaspersky antivirus like security. Where I
I'd like to change the security attribute of a directory that InstallShield creates under
I have created an Attribute, call MyAttribute, which is performing some security and for
Create a file called Valid[File].txt and stick some text in it. Start powershell and
Our's is a product specific to a domain.Here are some of the typical security
i am looking for svn admin a desktop application like VisualSVN Server only for
An application permits users to create records. For our purposes, let's call those records
I have create a getDBConnection method in my Java application. This returns a connection

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.