锁定当前屏幕触摸android,Android解锁屏幕,然后重新锁定屏幕(Nook简单触摸)

我的目标是有一个简单的程序,每X秒获取一次图像URL的内容,将其写入/ media/screensavers/Messages目录,然后解锁并重新锁定设备(Nook Simple Touch),以便显示新下载的图像。Android解锁屏幕,然后重新锁定屏幕(Nook简单触摸)

当它应该和图像下载时(我可以通过Android Studio logcat看到),警报会熄灭。问题是角落没有解锁。 (屏幕不更新)。

这里是AlarmReceiver.java

@Override

public void onReceive(Context context, Intent intent) {

// Log to logcat

Log.i("AlarmReceiver", "onReceive() -- onReceive fired! ");

// Create the dummy image url

String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());

String imgPath = new String();

imgPath = "http://dummyimage.com/600x800/fff/000.jpg&text=" + currentDateTimeString ;

imgPath = imgPath.replaceAll(" ", "+");

// Download and save the image (works great)

new DownloadImageTask().execute(imgPath);

// Now how do I a) unlock the device, then b) put it back to sleep?

}

Window win = getWindow();

win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

但getWindow()这个代码是RED(无法解析法)。

我试过使用context.getWindow(),但也有错误。如何从onReceiver上下文访问getWindow?

目标:通过

下载图片(完成)

写入图像目录(完成)

解锁装置

锁定devive

刷新 '屏幕保护程序' 的形象谢谢!

+0

'AlarmReceiver'没有这样的方法,你需要实现活动并启动它。 –

2014-12-27 20:14:21

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值