Android Display own lock instead of default when screen on/off

喜欢而已 提交于 2019-12-22 00:25:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!