List of usage examples for android.app NotificationManager cancel
public void cancel(int id)
From source file:net.micode.soundrecorder.RecorderService.java
private void localStartRecording(int outputfileformat, String path, boolean highQuality, long maxFileSize) { if (mRecorder == null) { mRemainingTimeCalculator.reset(); if (maxFileSize != -1) { mRemainingTimeCalculator.setFileSizeLimit(new File(path), maxFileSize); }/*from w ww.java2s .c om*/ mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT); if (outputfileformat == MediaRecorder.OutputFormat.THREE_GPP) { mRemainingTimeCalculator.setBitRate(SoundRecorder.BITRATE_3GPP); // mRecorder.setAudioChannels(1); mRecorder.setAudioSamplingRate(mAudioSampleRate); mRecorder.setAudioEncodingBitRate(SoundRecorder.BITRATE_3GPP); mRecorder.setOutputFormat(outputfileformat); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); } else if (outputfileformat == MediaRecorder.OutputFormat.AMR_NB) { mRemainingTimeCalculator.setBitRate(SoundRecorder.BITRATE_AMR); mRecorder.setAudioSamplingRate(highQuality ? 16000 : 8000); mRecorder.setOutputFormat(outputfileformat); mRecorder.setAudioEncoder( highQuality ? MediaRecorder.AudioEncoder.AMR_WB : MediaRecorder.AudioEncoder.AMR_NB); } else { mRemainingTimeCalculator.setBitRate(SoundRecorder.BITRATE_MP3); // mRecorder.setAudioChannels(1); mRecorder.setAudioSamplingRate(mAudioSampleRate); mRecorder.setAudioEncodingBitRate(SoundRecorder.BITRATE_MP3); mRecorder.setOutputFormat(outputfileformat); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); } mRecorder.setOutputFile(path); mRecorder.setOnErrorListener(this); // Handle IOException try { mRecorder.prepare(); } catch (IOException exception) { sendErrorBroadcast(Recorder.INTERNAL_ERROR); mRecorder.reset(); mRecorder.release(); mRecorder = null; return; } // Handle RuntimeException if the recording couldn't start try { mRecorder.start(); } catch (RuntimeException exception) { AudioManager audioMngr = (AudioManager) getSystemService(Context.AUDIO_SERVICE); boolean isInCall = (audioMngr.getMode() == AudioManager.MODE_IN_CALL); if (isInCall) { sendErrorBroadcast(Recorder.IN_CALL_RECORD_ERROR); } else { sendErrorBroadcast(Recorder.INTERNAL_ERROR); } mRecorder.reset(); mRecorder.release(); mRecorder = null; return; } mFilePath = path; mStartTime = System.currentTimeMillis(); mWakeLock.acquire(); mNeedUpdateRemainingTime = false; sendStateBroadcast(); showRecordingNotification(); NotificationManager nMgr = (NotificationManager) getApplicationContext() .getSystemService(NOTIFICATION_SERVICE); nMgr.cancel(notifyID); } }
From source file:net.kourlas.voipms_sms.activities.ConversationQuickReplyActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.conversation_quick_reply); database = Database.getInstance(getApplicationContext()); preferences = Preferences.getInstance(getApplicationContext()); contact = getIntent().getExtras().getString(getString(R.string.conversation_extra_contact)); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from ww w. j a v a 2 s . co m ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); } NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Integer notificationId = Notifications.getInstance(getApplicationContext()).getNotificationIds() .get(contact); if (notificationId != null) { manager.cancel(notificationId); } TextView replyToText = (TextView) findViewById(R.id.reply_to_edit_text); String contactName = Utils.getContactName(getApplicationContext(), contact); if (contactName == null) { replyToText.setText(getString(R.string.conversation_quick_reply_reply_to) + " " + Utils.getFormattedPhoneNumber(contact)); } else { replyToText.setText(getString(R.string.conversation_quick_reply_reply_to) + " " + contactName); } final EditText messageText = (EditText) findViewById(R.id.message_edit_text); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { messageText.setOutlineProvider(new ViewOutlineProvider() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(View view, Outline outline) { outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 15); } }); messageText.setClipToOutline(true); } messageText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { ViewSwitcher viewSwitcher = (ViewSwitcher) findViewById(R.id.view_switcher); if (s.toString().equals("") && viewSwitcher.getDisplayedChild() == 1) { viewSwitcher.setDisplayedChild(0); } else if (viewSwitcher.getDisplayedChild() == 0) { viewSwitcher.setDisplayedChild(1); } } }); QuickContactBadge photo = (QuickContactBadge) findViewById(R.id.photo); Utils.applyCircularMask(photo); photo.assignContactFromPhone(Preferences.getInstance(getApplicationContext()).getDid(), true); Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(Preferences.getInstance(getApplicationContext()).getDid())); Cursor cursor = getContentResolver().query(uri, new String[] { ContactsContract.PhoneLookup._ID, ContactsContract.PhoneLookup.PHOTO_THUMBNAIL_URI, ContactsContract.PhoneLookup.DISPLAY_NAME }, null, null, null); if (cursor.moveToFirst()) { String photoUri = cursor .getString(cursor.getColumnIndex(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI)); if (photoUri != null) { photo.setImageURI(Uri.parse(photoUri)); } else { photo.setImageToDefault(); } } else { photo.setImageToDefault(); } cursor.close(); final ImageButton sendButton = (ImageButton) findViewById(R.id.send_button); Utils.applyCircularMask(sendButton); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { preSendMessage(); } }); Button openAppButton = (Button) findViewById(R.id.open_app_button); openAppButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); Intent intent = new Intent(activity, ConversationActivity.class); intent.putExtra(getString(R.string.conversation_extra_contact), contact); TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext()); stackBuilder.addParentStack(ConversationActivity.class); stackBuilder.addNextIntent(intent); stackBuilder.startActivities(); } }); messageText.requestFocus(); }
From source file:edu.iub.seclab.appguardian.AppGuardianService.java
public void cancelNotification() { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); final int HELLO_ID = 1; mNotificationManager.cancel(HELLO_ID); }
From source file:de.androidbytes.adbconnect.presentation.services.WirelessAdbManagingService.java
private void clearNotification() { NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_ID); }
From source file:io.rapidpro.androidchannel.RapidPro.java
public void hideNotification() { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_ID); }
From source file:com.rareventure.gps2.GpsTrailerService.java
public void turnOffNotification() { NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.cancel(GTG.FROG_NOTIFICATION_ID); }
From source file:com.tvs.signaltracker.STService.java
private void StopWorks() { if (CommonHandler.ServiceMode < 3) ServiceHandler.removeCallbacks(ReSendRun); Log.i("SignalTracker::STService", "Stopping works"); try {/*from www . j a v a 2 s . c o m*/ if (mlocManager != null) { mlocManager.removeGpsStatusListener(GPSs); mlocManager.removeUpdates(GPSLocListener); mlocManager.removeUpdates(NetLocListener); } if (Tel != null) Tel.listen(MyListener, PhoneStateListener.LISTEN_NONE); } catch (Exception e) { } try { String ns = Context.NOTIFICATION_SERVICE; NotificationManager nMgr = (NotificationManager) this.getSystemService(ns); nMgr.cancel(NOTIFICATION); } catch (Exception e) { } GPSs = null; GPSLocListener = null; NetLocListener = null; CommonHandler.GPSFix = false; CommonHandler.NumSattelites = 0; Toast.makeText(getApplicationContext(), getResources().getString(R.string.stservicestopped), Toast.LENGTH_LONG).show(); LocalRunning = false; stopForeground(true); }
From source file:com.nextgis.mobile.TrackerService.java
@Override public void onDestroy() { Log.d(MainActivity.TAG, "onDestroy()"); super.onDestroy(); locationManager.removeUpdates(trackerLocationListener); if (trackerLocationListener.isWriteTrack()) trackerLocationListener.StoreTrack(false); SharedPreferences prefs = getSharedPreferences(PreferencesActivity.SERVICE_PREF, MODE_PRIVATE | MODE_MULTI_PROCESS); final SharedPreferences.Editor edit = prefs.edit(); edit.putBoolean(PreferencesActivity.KEY_PREF_SW_TRACKGPX_SRV, false); edit.commit();//ww w . ja v a 2 s . co m trackerLocationListener = null; NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(mNotifyId); }
From source file:com.nextgis.mobile.services.TrackerService.java
@Override public void onDestroy() { Log.d(TAG, "onDestroy()"); super.onDestroy(); locationManager.removeUpdates(trackerLocationListener); if (trackerLocationListener.isWriteTrack()) trackerLocationListener.StoreTrack(false); SharedPreferences prefs = getSharedPreferences(Constants.SERVICE_PREF, MODE_PRIVATE | MODE_MULTI_PROCESS); final SharedPreferences.Editor edit = prefs.edit(); edit.putBoolean(Constants.KEY_PREF_SW_TRACKGPX_SRV, false); edit.commit();/*w w w . jav a 2 s.c o m*/ trackerLocationListener = null; NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(mNotifyId); }