>我有一个问题。AddProximityAlert不想唤醒我的设备。我没有任何收款人(在这种情况下我不能有,因为无法取消注册)。我只是以这种方式推动意图添加邻近性意图:
Intent myIntent = new Intent(cxt, alarmView.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent proximityIntent = PendingIntent.getActivity(cxt, records.get(pos).process,myIntent, 0);
locationManager.addProximityAlert(records.get(pos).x,
records.get(pos).y, records.get(pos).r, // metry
-1, proximityIntent);
我尝试将PowerManager.newWakeLock插入myIntent.onCreate,但它不起作用(我认为是因为在唤醒之前未创建活动?
有可能为我的意图提供任何参数来唤醒我的手机或以其他方式进行?
(如果可能的话,我也想要解锁设备)
alarmView
活动中的 onCreate() 方法应该像:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
/**** Turn the screen on and show your activity ****/
android.view.Window window = getWindow();
window.addFlags(android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
window.addFlags(android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
window.setContentView(R.layout.activity_alarm_view);
/***************************************************/
/**** Rest of your code as it is ****/
/* ---------------------------- ****/
/************************************/
}
在这里,我假设此活动的布局文件的名称是activity_alarm_view.xml