【问题标题】:Android lock screen : activity started first when mobile onAndroid锁屏:移动时首先启动活动
【发布时间】:2014-04-11 12:14:57
【问题描述】:

我开发了一个应用程序手机号码锁定,我想要每当手机打开,或重新启动或打开,或者从手机上的顶部/左/右按钮打开时,只要手机屏幕在我的锁定活动调用时,我没有关于如何在移动时调用活动的想法请任何人给出一些相关的例子,以便在移动时首先启动活动。所以我的锁显示给用户,然后输入数字密码并打开锁......提前谢谢......

【问题讨论】:

    标签: android locking broadcastreceiver lockscreen


    【解决方案1】:

    以下对我有用:

    enter code here :
        public class BootReciever extends BroadcastReceiver {
    
     @Override
     public void onReceive(Context context, Intent intent) {
         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 menifist file add follwing:
    
    enter code here :
    <receiver android:name=".BootReciever">
            <intent-filter android:enabled="true" android:exported="true">
                <action android:name="android.intent.action.USER_PRESENT" />
            </intent-filter>
    </receiver>
    

    【讨论】:

      【解决方案2】:

      有多种方法可以实现这一目标。一种方法是您可以在手机启动后为您的应用程序广播一条消息。尝试阅读: http://developer.android.com/reference/android/content/BroadcastReceiver.html

      也看看这个线程,这将解决你的问题。 How to launch activity on BroadcastReceiver when boot complete on Android

      【讨论】:

      • 感谢您的回答,我已使用广播接收器,但我的问题是它仅在我的手机启动/重启时才有效,但我也想在我简单地打开/关闭手机或锁定它后显示活动,是的,我只需打开/关闭即可获得自动对话壁纸
      • 您能解释一下打开/关闭移动设备与启动/重启移动设备有何不同吗?
      • 手机自动锁定或被我们锁定 = 关闭然后我们锁定或在关闭该手机后启动手机
      • 表示当手机被锁定时,用户尝试锁定当时我想显示我自己的锁定(我的锁定活动)而不是移动默认锁定。
      • 我想确切地问这个用户请看这个链接并快速回答提前谢谢:stackoverflow.com/questions/23026308/…
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-01
      • 2015-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多