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);//
}
});