android实现消息提醒,拨打电话功能

本文介绍了如何在Android平台上实现消息提醒功能和拨打电话的功能。首先,详细讲解了利用Notification API创建和显示消息提醒的过程,包括设置通知的标题、内容、图标以及触发行为。接着,阐述了使用Intent和ACTION_CALL权限来启动电话拨打界面的方法,确保用户能够顺利拨出电话。这两个功能在许多Android应用中都具有实用价值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.消息提醒功能:

public class NotifyTest {
	public  static final int ID=1;
	private List<Homework>list;
	private Context context;
	private HomeworkDto dto;
	public NotifyTest(Context context,List<Homework> list) {
		super();
		this.list = list;
		this.context=context;
	}
	public void addNotificaction() {  
        NotificationManager manager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);  
        // 创建一个Notification  
        Notification notification = new Notification();  
        notification.icon = R.drawable.notify;// 设置显示在手机最上边的状态栏的图标  
        notification.tickerText = "亲,你有信息啦~~~";  // 当前的notification被放到状态栏上的时候,提示内容
       
  
        notification.defaults=Notification.DEFAULT_SOUND;// 添加声音提示  
        notification.audioStreamType= android.media.AudioManager.ADJUST_LOWER;//audioStreamType的值必须AudioManager中的值,代表着响铃的模式  
       
 
        Intent intent = new Intent(context, HomeworkActivity.class);//从一个activity跳到另外一个activity  
        Bundle mBundle = new Bundle();
        dto=new HomeworkDto(list);
		mBundle.putSerializable("homework", dto);
		intent.putExtras(mBundle);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT);  
        // 点击状态栏的图标出现的提示信息设置  
        notification.setLatestEventInfo(context, "通知:", "你最近有"+list.size()+"个作业要交,点击查看", pendingIntent);
        manager.notify(ID, notification); 

    }  

2.拨打电话功能:

listView.setOnItemClickListener(new OnItemClickListener() {//监听点击事件
	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1,
		int arg2, long arg3) {
		// TODO Auto-generated method stub
			
		 String string_phoneNum =numberList.get(arg2).getNumber();//得到电话号码
                 Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+string_phoneNum));//调用系统拨打电话服务       
		 startActivity(intent);//
					
				}
			});



 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值