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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:35:30+00:00 2026-05-24T09:35:30+00:00

I created my lockscreen application that trigerred by a SMS.. i have ListenSMS class

  • 0

I created my lockscreen application that trigerred by a SMS.. i have ListenSMS class that always listen for incoming SMS. Here’s the code :

for (SmsMessage message : messages) {
    String tempMessage[] = message.getDisplayMessageBody().toString().split(" ");

    //checking command dan password                             
    if (tempMessage[0].toString().equalsIgnoreCase("andro-lock") && tempMessage[1].toString().equals(tempPassword.toString())) {
        //Toast.makeText(ListenSMSservice.this, "Menjalankan command andro-lock", Toast.LENGTH_LONG).show();
        openDatabase();
        updateStatusL();
        Intent myIntent = new Intent(ListenSMSservice.this,LockScreenForm.class);
        myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        getApplication().startActivity(myIntent);
    }
    else if (tempMessage[0].toString().equalsIgnoreCase("andro-unlock") && tempMessage[1].toString().equals(tempPassword.toString())) {
        //Toast.makeText(ListenSMSservice.this, "Menjalankan command andro-unlock", Toast.LENGTH_LONG).show();
        openDatabase();
        updateStatusNL();                                                                   
        Intent myIntent = new Intent(ListenSMSservice.this,LockScreenForm.class);
        myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Bundle myKillerBundle = new Bundle();
        myKillerBundle.putString("kill","1");
        myIntent.putExtras(myKillerBundle);
        getApplication().startActivity(myIntent);
    }
}

If ListenSMS service has received an andro-lock command, it will go to the lockscreen.java and will go to the lockscreen.java with intent extra (putExtra) kill when it receive command andro-unclock. Here’s my lockscreen.java:

public class LockScreenForm extends Activity implements OnClickListener {
    /** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.lockscreen);             

        Bundle extra = getIntent().getExtras();
        if (extra == null) {
            return;
        }
        //Toast.makeText(this, extra.getString("kill"), 1).show();
        else if(this.getIntent().getExtras().getString("kill").equalsIgnoreCase("1")) {
            try {
                Toast.makeText(this, "extra accepted", 1).show();
                finish();
            } catch (Exception e) {
                // TODO: handle exception
                Toast.makeText(this, e.getMessage(), 1).show();
            }

        }

    }
}

I want to close my locksreen.java when my ListenSMS service has received “andro-unlock” command, so I put extra on intent “kill” and check it in lockscreen.java. This lockscreen.java can check the extra intent and can display a toast “extra accepted” but can close the lockscreen activity with finish().

My assumption is for now that Intent.FLAG_ACTIVITY_NEW_TASK is duplicating a locksreen activity. So it will create a double lockscreen activity and the finish method is closing another lockscreen.java that started by Intent.FLAG_ACTIVITY_NEW_TASK. That’s only assumption. Am i wrong? Please correct me.

Has anyone know how to solve my problem? I really want that “andro-unlock” command can close the lockscreen activity and need it works for my college final project. Please help.

  • 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-24T09:35:33+00:00Added an answer on May 24, 2026 at 9:35 am

    From http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_TASK:

    When using this flag, if a task is already running for the activity you are now starting, then a new activity will not be started; instead, the current task will simply be brought to the front of the screen with the state it was last in. See FLAG_ACTIVITY_MULTIPLE_TASK for a flag to disable this behavior. 
    

    I expect your problem is somewhere else. I’d suggest having the lockscreen Activity register a BroadcastReceiver, and then when the unlock message is received send an Intent that the BroadcastReceiver will catch. The Activity can then cleanly exit.

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

Sidebar

Related Questions

I created a Rails application normally. Then created the scaffold for an event class.
I created a few mediawiki custom tags, using the guide found here http://www.mediawiki.org/wiki/Manual:Tag_extensions I
I created a single page (with code behind .vb) and created Public intFileID As
I created a simple .NET windows application in Visual Studio 2005 and on just
Created application is working toooo slow, looks like there are a lot of memory
created a singleview application with storyboard. Added three viewcontrollers apart from the one view
Created a UITextField for Postal Code/ZIP field with a keyboardType of UIKeyboardTypeDefault. I would
Created a google map with GMap2 and put pinpoints on there that open up
I have a UIViewController subclass called TripViewController. This class has the following method: -
Created a stored procedure in SQL 9 (2005) and have since upgraded to SQL

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.