【发布时间】:2014-04-11 12:14:57
【问题描述】:
我开发了一个应用程序手机号码锁定,我想要每当手机打开,或重新启动或打开,或者从手机上的顶部/左/右按钮打开时,只要手机屏幕在我的锁定活动调用时,我没有关于如何在移动时调用活动的想法请任何人给出一些相关的例子,以便在移动时首先启动活动。所以我的锁显示给用户,然后输入数字密码并打开锁......提前谢谢......
【问题讨论】:
标签: android locking broadcastreceiver lockscreen
我开发了一个应用程序手机号码锁定,我想要每当手机打开,或重新启动或打开,或者从手机上的顶部/左/右按钮打开时,只要手机屏幕在我的锁定活动调用时,我没有关于如何在移动时调用活动的想法请任何人给出一些相关的例子,以便在移动时首先启动活动。所以我的锁显示给用户,然后输入数字密码并打开锁......提前谢谢......
【问题讨论】:
标签: android locking broadcastreceiver lockscreen
以下对我有用:
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>
【讨论】:
有多种方法可以实现这一目标。一种方法是您可以在手机启动后为您的应用程序广播一条消息。尝试阅读: http://developer.android.com/reference/android/content/BroadcastReceiver.html
也看看这个线程,这将解决你的问题。 How to launch activity on BroadcastReceiver when boot complete on Android
【讨论】: