public void showsrstatus() {
SrNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification srnotification = new Notification();
srnotification.icon = R.drawable.ic_launcher_soundrecorder;
srnotification.tickerText = "Soundrecorder";
srnotification.when = System.currentTimeMillis();
srnotification.flags = srnotification.FLAG_ONGOING_EVENT;
Intent intent = new Intent(SoundRecorder.this, SoundRecorder.class);
PendingIntent pi = PendingIntent.getActivity(SoundRecorder.this, 0,
intent, 0); // 消息触发后调用
srnotification.setLatestEventInfo(SoundRecorder.this, " "
+ getResources().getString(R.string.app_name), getResources()
.getString(R.string.record_your_message), pi);
SrNotificationManager.notify(SR_NOTIFI_ID, srnotification);
}
public void closesrstatus() {
SrNotificationManager.cancel(SR_NOTIFI_ID);
}
如果只想唤起一个activity , 则要在manifest里
设置 android:launchMode="singleTask"
本文介绍了一个简单的Android应用程序中用于显示和关闭录音状态栏通知的方法。通过创建自定义的通知并在需要的时候展示出来,可以让用户了解录音正在进行的状态。同时,提供了如何在AndroidManifest.xml中配置Activity以确保只有一个实例运行。
1076

被折叠的 条评论
为什么被折叠?



