0

When I open my screnn I want to make my app open. It is password application and I want that EVERY time that the screnn open the app will ask the password.

I made all the code that i need for the app but it is not working and the app does not open. I used RECEIVE_BOOT_COMPLETED:

<user-permission android:name="android.intent.category.RECEIVE_BOOT_COMPLETED" />
<application
  ...
   <receiver
      android:name="com.test.receiver"
      android:enabled="true" >
      <intent-filter>
         <action android:name="android.intent.action.SCREEN_ON" />
         <action android:name="android.intent.action.BOOT_COMPLETED" />
      </intent-filter>
   </receiver>
</application>

and here is the java part:

public class receiver extends BroadcastReceiver
{
   @Override
   public void onReceive(Context context, Intent intent)
   {
      intent = new Intent(context, MainActivity.class);
      startActivity(intent); // context.startActivity(intent); does not work too
   }
}

i will be happy if someone will help me, and if someone can say too me how acn i cancel somehow the home button i will be thanksful a lot :)

  • See my answer [here](http://stackoverflow.com/questions/16657300/disable-all-home-button-and-task-bar-features-on-nexus-7/16657359#16657359) for disabling the home button and starting an activity from a BroadcastReceiver. – TronicZomB Jul 30 '13 at 19:18
  • Though I think there may be a better way to achieve what you are looking for. – TronicZomB Jul 30 '13 at 19:26

1 Answers1

1

Other SO posts suggest you will need to use this code for your app to appear above the lock screen;

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
    WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
    WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

Android activity over default lock screen


Further SO posts suggest you will need to do something like this so that you can unlock the phone with your application;

Permission: <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>

mKeyGuardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
    mLock = mKeyGuardManager.newKeyguardLock("activity_classname");
    mLock.disableKeyguard();

Lock the android device programmatically (Someone says that method is obsolete, but the docs seem to disagree)

Community
  • 1
  • 1
Robadob
  • 5,319
  • 2
  • 23
  • 32
  • Just remember that if you use this method, it still will not work if the user has a password(pin,pattern,etc) it will not work as you cannot bypass it with the flags above. – ObieMD5 Jul 30 '13 at 19:24
  • so it will work after the password was typed? or it is just won't open? –  Aug 05 '13 at 15:49
  • The second part under the `
    ` was added to cover methods for bypassing the password.
    – Robadob Aug 05 '13 at 15:50