List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TASK
int FLAG_ACTIVITY_CLEAR_TASK
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TASK.
Click Source Link
From source file:com.digigene.autoupdate.presenter.DownloadDialogPresenterImpl.java
private void doWhenDownloadIsFinishedInForcedMode(String fileName) { File directory = context.getExternalFilesDir(null); File file = new File(directory, fileName); Uri fileUri = Uri.fromFile(file);/*from w w w .ja va 2s . c o m*/ if (Build.VERSION.SDK_INT >= 24) { fileUri = FileProvider.getUriForFile(context, context.getPackageName(), file); } Intent intent = new Intent(Intent.ACTION_VIEW, fileUri); intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true); intent.setDataAndType(fileUri, "application/vnd.android" + ".package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity(intent); activity.finish(); }
From source file:org.gateshipone.odyssey.playbackservice.managers.OdysseyNotificationManager.java
public void updateNotification(TrackModel track, PlaybackService.PLAYSTATE state, MediaSessionCompat.Token mediaSessionToken) { if (track != null) { mNotificationBuilder = new NotificationCompat.Builder(mContext); // Open application intent Intent contentIntent = new Intent(mContext, OdysseyMainActivity.class); contentIntent.putExtra(OdysseyMainActivity.MAINACTIVITY_INTENT_EXTRA_REQUESTEDVIEW, OdysseyMainActivity.MAINACTIVITY_INTENT_EXTRA_REQUESTEDVIEW_NOWPLAYINGVIEW); contentIntent.addFlags(/*from w w w . j a v a2 s. c o m*/ Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_HISTORY); PendingIntent contentPendingIntent = PendingIntent.getActivity(mContext, NOTIFICATION_INTENT_OPENGUI, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT); mNotificationBuilder.setContentIntent(contentPendingIntent); // Set pendingintents // Previous song action Intent prevIntent = new Intent(PlaybackService.ACTION_PREVIOUS); PendingIntent prevPendingIntent = PendingIntent.getBroadcast(mContext, NOTIFICATION_INTENT_PREVIOUS, prevIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action prevAction = new NotificationCompat.Action.Builder( R.drawable.ic_skip_previous_48dp, "Previous", prevPendingIntent).build(); // Pause/Play action PendingIntent playPauseIntent; int playPauseIcon; if (state == PlaybackService.PLAYSTATE.PLAYING) { Intent pauseIntent = new Intent(PlaybackService.ACTION_PAUSE); playPauseIntent = PendingIntent.getBroadcast(mContext, NOTIFICATION_INTENT_PLAYPAUSE, pauseIntent, PendingIntent.FLAG_UPDATE_CURRENT); playPauseIcon = R.drawable.ic_pause_48dp; } else { Intent playIntent = new Intent(PlaybackService.ACTION_PLAY); playPauseIntent = PendingIntent.getBroadcast(mContext, NOTIFICATION_INTENT_PLAYPAUSE, playIntent, PendingIntent.FLAG_UPDATE_CURRENT); playPauseIcon = R.drawable.ic_play_arrow_48dp; } NotificationCompat.Action playPauseAction = new NotificationCompat.Action.Builder(playPauseIcon, "PlayPause", playPauseIntent).build(); // Next song action Intent nextIntent = new Intent(PlaybackService.ACTION_NEXT); PendingIntent nextPendingIntent = PendingIntent.getBroadcast(mContext, NOTIFICATION_INTENT_NEXT, nextIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action nextAction = new NotificationCompat.Action.Builder( R.drawable.ic_skip_next_48dp, "Next", nextPendingIntent).build(); // Quit action Intent quitIntent = new Intent(PlaybackService.ACTION_QUIT); PendingIntent quitPendingIntent = PendingIntent.getBroadcast(mContext, NOTIFICATION_INTENT_QUIT, quitIntent, PendingIntent.FLAG_UPDATE_CURRENT); mNotificationBuilder.setDeleteIntent(quitPendingIntent); mNotificationBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); mNotificationBuilder.setSmallIcon(R.drawable.odyssey_notification); mNotificationBuilder.addAction(prevAction); mNotificationBuilder.addAction(playPauseAction); mNotificationBuilder.addAction(nextAction); NotificationCompat.MediaStyle notificationStyle = new NotificationCompat.MediaStyle(); notificationStyle.setShowActionsInCompactView(1, 2); notificationStyle.setMediaSession(mediaSessionToken); mNotificationBuilder.setStyle(notificationStyle); mNotificationBuilder.setContentTitle(track.getTrackName()); mNotificationBuilder.setContentText(track.getTrackArtistName()); // Remove unnecessary time info mNotificationBuilder.setWhen(0); // Cover but only if changed if (mLastTrack == null || !track.getTrackAlbumKey().equals(mLastTrack.getTrackAlbumKey())) { mLastTrack = track; mLastBitmap = null; } // Only set image if an saved one is available if (mLastBitmap != null) { mNotificationBuilder.setLargeIcon(mLastBitmap); } else { /** * Create a dummy placeholder image for versions greater android 7 because it * does not automatically show the application icon anymore in mediastyle notifications. */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Drawable icon = mContext.getDrawable(R.drawable.notification_placeholder_256dp); Bitmap iconBitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(iconBitmap); DrawFilter filter = new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG, 1); canvas.setDrawFilter(filter); icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); icon.setFilterBitmap(true); icon.draw(canvas); mNotificationBuilder.setLargeIcon(iconBitmap); } else { /** * For older android versions set the null icon which will result in a dummy icon * generated from the application icon. */ mNotificationBuilder.setLargeIcon(null); } } // Build the notification mNotification = mNotificationBuilder.build(); // Check if run from service and check if playing or pause. // Pause notification should be dismissible. if (mContext instanceof Service) { if (state == PlaybackService.PLAYSTATE.PLAYING) { ((Service) mContext).startForeground(NOTIFICATION_ID, mNotification); } else { ((Service) mContext).stopForeground(false); } } // Send the notification away mNotificationManager.notify(NOTIFICATION_ID, mNotification); } }
From source file:com.crea_si.eviacam.service.SplashActivity.java
private void checkRequisites() { if (!Eula.wasAccepted(this)) { Eula.acceptEula(this, this); return;/* w ww .j a v a 2s. co m*/ } if (checkPermissions()) { // If all permissions granted resume service initialization // TODO: remove such ugly static method call MainEngine.splashReady(isA11YService()); /** * Restart this activity so that it does not show up in recents * nor when pressing back button */ Intent dialogIntent = new Intent(this, SplashActivity.class); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_NO_HISTORY); dialogIntent.putExtra(IS_A11Y_SERVICE_PARAM, isA11YService()); dialogIntent.putExtra(IS_SECOND_RUN_PARAM, true); startActivity(dialogIntent); } }
From source file:id.satusatudua.sigap.ui.LoginActivity.java
@OnClick(R.id.forgot_password) public void forgotPassword() { String email = this.email.getText().toString(); if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) { this.email.setError("Mohon masukan alamat email yang valid terlebih dahulu!"); } else {//from w w w. j a va 2 s . c o m showLoading(); FirebaseApi.pluck().getApi().resetPassword(email, new Firebase.ResultHandler() { @Override public void onSuccess() { dismissLoading(); new AlertDialog.Builder(LoginActivity.this).setIcon(R.mipmap.ic_launcher) .setTitle(R.string.app_name).setCancelable(false) .setMessage( "Kami telah mengirimkan sebuah kode ke email yang anda masukan tadi, masukan kode tersebut ke form selanjutnya untuk mengubah kata sandi anda.") .setPositiveButton("OK", (dialog, which) -> { StateManager.pluck().setState(StateManager.State.ENTER_CODE); StateManager.pluck().setLastEmail(email); Intent intent = new Intent(LoginActivity.this, EnterCodeActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); }).show().getButton(DialogInterface.BUTTON_POSITIVE) .setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.colorPrimary)); } @Override public void onError(FirebaseError firebaseError) { dismissLoading(); Snackbar snackbar = Snackbar.make(password, firebaseError.getMessage(), Snackbar.LENGTH_LONG); snackbar.getView().setBackgroundResource(R.color.colorAccent); snackbar.show(); } }); } }
From source file:com.begentgroup.miniproject.gcm.MyGcmListenerService.java
private void sendNotification(ChatMessage m) { Intent intent = new Intent(this, SplashActivity.class); intent.putExtra(ChatActivity.EXTRA_USER, m.getSender()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setTicker("Chat Message") .setContentTitle(m.getSender().getUserName()).setContentText(m.getMessage()).setAutoCancel(true) .setDefaults(NotificationCompat.DEFAULT_ALL).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.example.pc.mylauncher.ScreenSlideActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_screen_slide); // Instantiate a ViewPager and a PagerAdapter. mPager = (NonSwipeableViewPager) findViewById(R.id.pager); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabDots); tabLayout.setupWithViewPager(mPager, true); mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); mPager.setAdapter(mPagerAdapter);// www. j a v a 2 s. c o m mPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When changing pages, reset the action bar actions since they are dependent // on which page is currently active. An alternative approach is to have each // fragment expose actions itself (rather than the activity exposing actions), // but for simplicity, the activity provides the actions in this sample. // invalidateOptionsMenu(); } }); mPager.setPageTransformer(true, new ZoomOutPageTransformer()); mNextButton = (Button) findViewById(R.id.next_button); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mNextButton .setText((mPager.getCurrentItem() >= mPagerAdapter.getCount() - 2) ? R.string.action_finish : R.string.action_next); if (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) { SharedPreferences applicationPreferences = PreferenceManager .getDefaultSharedPreferences(ScreenSlideActivity.this); applicationPreferences.edit().putBoolean("showWelcome", false).apply(); // getPackageManager().setComponentEnabledSetting(new ComponentName(getPackageName(), MainAppActivity.class.getName()), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0); // getPackageManager().setComponentEnabledSetting(new ComponentName(getPackageName(), ScreenSlideActivity.class.getName()), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); Intent intent = new Intent(ScreenSlideActivity.this, MainAppActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); //intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); } else { mPager.setCurrentItem(mPager.getCurrentItem() + 1); } } }); }
From source file:net.clcworld.thermometer.TakeTemperatureReadingActivity.java
/** Called when the activity is first created. */ @Override//from w ww .j a v a2 s. c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSelf = this; Intent i = new Intent(); i.setClass(this, LauncherActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent relaunchIntent = PendingIntent.getActivity(this, 0, i, 0); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent data = this.getIntent(); if (data.getBooleanExtra("FROM_ALARM", false)) { // Only show the persistant notification if it's from the alarm. NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.app_icon).setTicker(getString(R.string.notification)) .setContentTitle(getString(R.string.app_name)).setContentText(getString(R.string.notification)) .setOngoing(true).setOnlyAlertOnce(false).setContentIntent(relaunchIntent) .setSound(Settings.System.DEFAULT_NOTIFICATION_URI).setLights(Color.RED, 500, 500); mNotificationManager.notify(NOTIFICATION_NUMBER, builder.build()); } mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mFeeling = mPrefs.getString("lastFeeling", STATUS_WELL); mHistory = mPrefs.getString(PREFSKEY_HISTORY, ""); final String id = mPrefs.getString("ID", ""); setContentView(R.layout.temperature); mTemperatureEditText = (EditText) findViewById(R.id.temperature); mTemperatureEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { hideKeyboard(v); } } }); final LinearLayout symptomsList = (LinearLayout) findViewById(R.id.symptoms); final CheckBox extremeTiredness = (CheckBox) findViewById(R.id.extremetiredness); if (mPrefs.getBoolean(PREFSKEY_SYMPTOMS_EXTREMETIREDNESS, false)) { extremeTiredness.setChecked(true); } final CheckBox musclepain = (CheckBox) findViewById(R.id.musclepain); if (mPrefs.getBoolean(PREFSKEY_SYMPTOMS_MUSCLEPAIN, false)) { musclepain.setChecked(true); } final CheckBox headache = (CheckBox) findViewById(R.id.headache); if (mPrefs.getBoolean(PREFSKEY_SYMPTOMS_HEADACHE, false)) { headache.setChecked(true); } final CheckBox sorethroat = (CheckBox) findViewById(R.id.sorethroat); if (mPrefs.getBoolean(PREFSKEY_SYMPTOMS_SORETHROAT, false)) { sorethroat.setChecked(true); } final CheckBox vomiting = (CheckBox) findViewById(R.id.vomiting); if (mPrefs.getBoolean(PREFSKEY_SYMPTOMS_VOMITING, false)) { vomiting.setChecked(true); } final CheckBox diarrhea = (CheckBox) findViewById(R.id.diarrhea); if (mPrefs.getBoolean(PREFSKEY_SYMPTOMS_DIARRHEA, false)) { diarrhea.setChecked(true); } final CheckBox rash = (CheckBox) findViewById(R.id.rash); if (mPrefs.getBoolean(PREFSKEY_SYMPTOMS_RASH, false)) { rash.setChecked(true); } final CheckBox bleeding = (CheckBox) findViewById(R.id.bleeding); if (mPrefs.getBoolean(PREFSKEY_SYMPTOMS_BLEEDING, false)) { bleeding.setChecked(true); } final CheckBox painrelief = (CheckBox) findViewById(R.id.painrelief); if (mPrefs.getBoolean(PREFSKEY_SYMPTOMS_PAINRELIEF, false)) { painrelief.setChecked(true); } final Button submitButton = (Button) findViewById(R.id.submit); submitButton.setText(R.string.save); final String destination = mPrefs.getString("DEST", ""); if (destination.length() > 0) { submitButton.setText(getString(R.string.submit) + destination); } submitButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { String tempString = mTemperatureEditText.getText().toString(); try { float t = Float.parseFloat(tempString); // Come up with better thresholds + use an alert // confirmation prompt. if ((t < 91) || (t > 120)) { Toast.makeText(mSelf, R.string.retake, Toast.LENGTH_LONG).show(); return; } mTemperatureEditText.setEnabled(false); submitButton.setEnabled(false); Editor editor = mPrefs.edit(); editor.putLong("LAST_READING", System.currentTimeMillis()); ArrayList<String> symptoms = new ArrayList<String>(); if (mFeeling.equals(STATUS_WELL)) { editor.putBoolean(PREFSKEY_SYMPTOMS_EXTREMETIREDNESS, false); editor.putBoolean(PREFSKEY_SYMPTOMS_MUSCLEPAIN, false); editor.putBoolean(PREFSKEY_SYMPTOMS_HEADACHE, false); editor.putBoolean(PREFSKEY_SYMPTOMS_SORETHROAT, false); editor.putBoolean(PREFSKEY_SYMPTOMS_VOMITING, false); editor.putBoolean(PREFSKEY_SYMPTOMS_DIARRHEA, false); editor.putBoolean(PREFSKEY_SYMPTOMS_RASH, false); editor.putBoolean(PREFSKEY_SYMPTOMS_BLEEDING, false); editor.putBoolean(PREFSKEY_SYMPTOMS_PAINRELIEF, false); } else { if (extremeTiredness.isChecked()) { editor.putBoolean(PREFSKEY_SYMPTOMS_EXTREMETIREDNESS, true); symptoms.add(PREFSKEY_SYMPTOMS_EXTREMETIREDNESS); } if (musclepain.isChecked()) { editor.putBoolean(PREFSKEY_SYMPTOMS_MUSCLEPAIN, true); symptoms.add(PREFSKEY_SYMPTOMS_MUSCLEPAIN); } if (headache.isChecked()) { editor.putBoolean(PREFSKEY_SYMPTOMS_HEADACHE, true); symptoms.add(PREFSKEY_SYMPTOMS_HEADACHE); } if (sorethroat.isChecked()) { editor.putBoolean(PREFSKEY_SYMPTOMS_SORETHROAT, true); symptoms.add(PREFSKEY_SYMPTOMS_SORETHROAT); } if (vomiting.isChecked()) { editor.putBoolean(PREFSKEY_SYMPTOMS_VOMITING, true); symptoms.add(PREFSKEY_SYMPTOMS_VOMITING); } if (diarrhea.isChecked()) { editor.putBoolean(PREFSKEY_SYMPTOMS_DIARRHEA, true); symptoms.add(PREFSKEY_SYMPTOMS_DIARRHEA); } if (rash.isChecked()) { editor.putBoolean(PREFSKEY_SYMPTOMS_RASH, true); symptoms.add(PREFSKEY_SYMPTOMS_RASH); } if (bleeding.isChecked()) { editor.putBoolean(PREFSKEY_SYMPTOMS_BLEEDING, true); symptoms.add(PREFSKEY_SYMPTOMS_BLEEDING); } if (painrelief.isChecked()) { editor.putBoolean(PREFSKEY_SYMPTOMS_PAINRELIEF, true); symptoms.add(PREFSKEY_SYMPTOMS_PAINRELIEF); } } editor.commit(); mNotificationManager.cancelAll(); DecimalFormat decFormat = new DecimalFormat("0.0"); sendData(id, decFormat.format(t), mFeeling, symptoms); } catch (Exception e) { e.printStackTrace(); } } }); mFeelingRadioGroup = (RadioGroup) findViewById(R.id.radioGroupFeeling); int selectedId = R.id.radioWell; if (mFeeling.equals(STATUS_SICK)) { selectedId = R.id.radioSick; if (destination.length() > 0) { symptomsList.setVisibility(View.VISIBLE); } } mFeelingRadioGroup.check(selectedId); mFeelingRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (checkedId == R.id.radioSick) { mFeeling = STATUS_SICK; if (destination.length() > 0) { symptomsList.setVisibility(View.VISIBLE); } } else { mFeeling = STATUS_WELL; symptomsList.setVisibility(View.GONE); } Editor editor = mPrefs.edit(); editor.putString("lastFeeling", mFeeling); editor.commit(); } }); Button historyButton = (Button) findViewById(R.id.history); if (mHistory.length() < 1) { historyButton.setVisibility(View.GONE); } historyButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mSelf); alertDialogBuilder.setTitle(R.string.history); alertDialogBuilder.setPositiveButton(R.string.ok, null); AlertDialog dialog = alertDialogBuilder.create(); TextView text = new TextView(mSelf); text.setTextSize(16); text.setPadding(40, 40, 40, 40); text.setText(mHistory); ScrollView scroll = new ScrollView(mSelf); scroll.addView(text); dialog.setView(scroll); dialog.show(); } }); Button viewTosButton = (Button) findViewById(R.id.viewtos); viewTosButton.setText(R.string.tos_title_local); mIsActivated = false; if (destination.length() > 0) { mIsActivated = true; viewTosButton.setText(R.string.tos_title_publichealth); } viewTosButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent viewTosIntent = new Intent(); viewTosIntent.setClass(mSelf, TosActivity.class); viewTosIntent.putExtra("VIEW_ONLY", true); startActivity(viewTosIntent); } }); }
From source file:id.zelory.codepolitan.ui.fragment.ChooseCategoryFragment.java
private void submit(View view) { Intent intent = new Intent(getActivity(), MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent);//from w w w . j a v a 2s. com getActivity().finish(); }
From source file:samples.piggate.com.piggateInfoDemo.InfoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_artwork); //Set action bar fields getSupportActionBar().setTitle(PiggateUser.getEmail()); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); title = (TextView) findViewById(R.id.InfoTitle); description = (TextView) findViewById(R.id.InfoDescription); image = (SmartImageView) findViewById(R.id.InfoImage); videoButton = (FloatingActionButton) findViewById(R.id.videoButton); errorDialog = new AlertDialog.Builder(this).create(); errorDialog.setTitle("Logout error"); errorDialog.setMessage("There is an error with the logout"); errorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override// w ww.ja v a2 s . c om public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); networkErrorDialog = new AlertDialog.Builder(this).create(); networkErrorDialog.setTitle("Network error"); networkErrorDialog.setMessage("There is an error with the network connection"); networkErrorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); title.setText(getIntent().getExtras().getString("infoTitle")); description.setText(getIntent().getExtras().getString("infoDescription")); image.setImageUrl(getIntent().getExtras().getString("infoImageURL")); videoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (checkInternetConnection() == true) { //If internet is working //Start the video here Intent slideactivity = new Intent(getApplicationContext(), VideoViewActivity.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); //Information about selected content slideactivity.putExtra("infoTitle", getIntent().getExtras().getString("infoTitle")); slideactivity.putExtra("infoDescription", getIntent().getExtras().getString("infoDescription")); slideactivity.putExtra("infoImageURL", getIntent().getExtras().getString("infoImageURL")); slideactivity.putExtra("infoVideoURL", getIntent().getExtras().getString("infoVideoURL")); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft) .toBundle(); getApplicationContext().startActivity(slideactivity, bndlanimation); } else { //If internet conexion is not working displays an error message networkErrorDialog.show(); } } }); }
From source file:com.heightechllc.breakify.AlarmNotifications.java
/** * Shows a notification to let the user know that the time is up * @param context The context to create the notification from * @param workState The work state of the finished timer *//* ww w . j ava 2s . c om*/ public static void showRingNotification(Context context, int workState) { // Create the notification NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(R.drawable.ic_notification).setPriority(NotificationCompat.PRIORITY_MAX) .setContentTitle(context.getString(R.string.notif_ring_title)) .setDefaults(NotificationCompat.DEFAULT_LIGHTS); // Get the appropriate text based on the current work state int textId = workState == MainActivity.WORK_STATE_WORKING ? R.string.notif_ring_content_text_working : R.string.notif_ring_content_text_breaking; builder.setContentText(context.getString(textId)); // Set up the action for when the notification is clicked - to open MainActivity, which // will open RingingActivity Intent mainIntent = new Intent(context, MainActivity.class); mainIntent.putExtra(MainActivity.EXTRA_ALARM_RING, true); mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pi = PendingIntent.getActivity(context, 0, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(pi); // Add "Snooze" action for expanded notification Intent snoozeIntent = new Intent(context, MainActivity.class); snoozeIntent.putExtra(MainActivity.EXTRA_SNOOZE, true); snoozeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent snoozePi = PendingIntent.getActivity(context, 1, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(R.drawable.ic_action_snooze, context.getString(R.string.snooze), snoozePi); // Show the notification NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(notificationID, builder.build()); }