alarm

Posted cuthead

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了alarm相关的知识,希望对你有一定的参考价值。

package com.example.alarm;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class RefreshBroadcastReceiver extends BroadcastReceiver {
	public void onReceive(Context context, Intent intent) {
		Toast.makeText(context, "kym I love you", Toast.LENGTH_SHORT).show();
		}
}

  

package com.example.alarm;

import android.os.Bundle;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.app.AlarmManager;

public class MainActivity extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        AlarmManager manager = (AlarmManager) getSystemService(ALARM_SERVICE);
		Intent intent2 = new Intent(this, RefreshBroadcastReceiver.class);
		PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent2, 0);
		manager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 100, 100, pi);
    }
}

  

以上是关于alarm的主要内容,如果未能解决你的问题,请参考以下文章

alarm函数

如何编写 terraform 代码来为过多的数据库连接创建 aws_cloudwatch_metric_alarm?

alarm(),sleep(),pause()

C 中的 alarm() 和 SIGALRM 问题

php中pcntl_alarm为函数设置超时限制

lua: init.lua:15: 尝试调用方法 'alarm' (一个 nil 值)