i created lock screen application.. Sometimes it give me a problem. problem is that some time default lock screen display rather than my lock screen and some time directly home screen display. i donot know where is the problem. please give me suggestion about this.
LockScreenActivity:
Use
and create ScreenReceiver:
Refer this link: <a href="http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/" rel="nofollow">http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/</a>
in manifeast file : declare service and receiver and permission
The problem is in BroadcastReceiver when
but the activity call after screen on.. so what is missing or what is problem.. why it is happn pls rply.
Hi here is my code :
The activity is calling after when action screen on is call .
LockScreenActivity:
Use
Code:
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();
and create ScreenReceiver:
Code:
ACTION_SCREEN_OFF
ACTION_SCREEN_ON
ACTION_BOOT_COMPLETED
Refer this link: <a href="http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/" rel="nofollow">http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/</a>
in manifeast file : declare service and receiver and permission
The problem is in BroadcastReceiver when
Code:
if (recievedIntent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
//call activity
}else if (recievedIntent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
}
but the activity call after screen on.. so what is missing or what is problem.. why it is happn pls rply.
Hi here is my code :
Code:
public class myReceiver extends BroadcastReceiver {
public static boolean wasScreenOn = true;
@Override
public void onReceive(final Context context, Intent recievedIntent) {
if (recievedIntent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
wasScreenOn = false;
Intent intent = new Intent(context,
myActivity.class);
intent.setAction(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
context.startActivity(intent
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} else if (recievedIntent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
wasScreenOn = true;
}
}
}
The activity is calling after when action screen on is call .