问题
i want to open my created lock instead of default one,when phone is boot at that time my lock is called. But i want to know when my screen on after locked at that time how i called my lock (my lock activity)Means i want to display my lock instead of default at time of screen on or phone restart or switch on all time. like in our phone lock called all time same as i want to call my lock all time( done with boot ).so please any one help me how i call my lock when screen on/off.please help quickly thanks.... i do for boot time call my lock following exactly i that i want for screen-on/off
{ <receiver
android:name=".BootReciever"
android:enabled="true"
android:exported="true" >
<intent-filter android:priority="1" >
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver> } in menifest
回答1:
I give my own answers : use follwing method in my BootReciever class :
`enter code here`
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent.getAction() != null) {
if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)) {
Intent s = new Intent(context,ViewPagerMainActivity.class);
s.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(s);
}
}
}
and in menifest file use follwing :
enter code here : use : <action android:name="android.intent.action.USER_PRESENT" />
<receiver
android:name=".BootReciever"
android:enabled="true"
android:exported="false" >
<intent-filter android:priority="1" >
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.SCREEN_OFF" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
来源:https://stackoverflow.com/questions/23026308/android-display-own-lock-instead-of-default-when-screen-on-off