2022年11月

最近接手了公司Android项目,一直在处理Android项目的App的开发,作为半路起家,总结了一些Android开发的心得和知识点,然后就写下来记录一下,分享给有需要的人看,那么本篇博文就来分享一下在Android开发过程中,涉及到获取系统当前日期和时间的方法,知识点虽然简单,但是很实用。

Android获取当前系统日期和时间,大概分为三种方式,具体如下所示:

- 阅读剩余部分 -

启动程序时启动一个 service,在 service 里注册接收短信的广播,当手机收到短信里,打印出短信内容跟电话号码。

package com.lmy.SmsListener;
 
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
 
public class SmsListenerActivity extends Activity {
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.main);
        TextView tv = new TextView(this);
        tv.setText("Hello. I started!");
        setContentView(tv);
        Intent service = new Intent(this, MyService.class);
        this.startService(service);
    }
}

- 阅读剩余部分 -