我开发了一个应用程序手机号码锁,我希望无论何时移动,重新启动或打开,或从上/左/右按钮放置在手机上--总之,每当我的锁定活动呼叫移动屏幕时,我不知道如何在移动时调用活动--请给出一些相关的示例,以便在移动启动时开始活动。因此,我的锁不支付给用户,然后输入号码密码,并预先锁定打开...thanks。
发布于 2014-04-12 09:39:59
以下是我的工作:
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>发布于 2014-04-11 12:18:17
要实现这一点,有多种方法。一种方法是,您可以通过广播消息为您的应用程序,在启动后,您的手机。试着阅读:http://developer.android.com/reference/android/content/BroadcastReceiver.html
也看过这个帖子,这会解决你的问题。How to launch activity on BroadcastReceiver when boot complete on Android
https://stackoverflow.com/questions/23012278
复制相似问题