List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TOP
int FLAG_ACTIVITY_CLEAR_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.
Click Source Link
From source file:com.cloudexplorers.plugins.childBrowser.ChildBrowser.java
/** * Display a new browser with the specified URL. * // w w w . j a va 2 s. c o m * @param url * The url to load. * @param usePhoneGap * Load url in PhoneGap webview * @return "" if ok, or error message. */ public String openExternal(String urlToOpen, String encodedCredentials) { try { // set the download URL, a url that points to a file on the internet // this is the file to be downloaded URL url = new URL(urlToOpen); // create the new connection HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); // set up some things on the connection urlConnection.setRequestMethod("GET"); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Authorization", encodedCredentials); // and connect! urlConnection.connect(); // set the path where we want to save the file // in this case, going to save it on the root directory of the // sd card. File SDCardRoot = Environment.getExternalStorageDirectory(); // create a new file, specifying the path, and the filename // which we want to save the file as. File file = new File(SDCardRoot, "temp.pdf"); // this will be used to write the downloaded data into the file we created FileOutputStream fileOutput = new FileOutputStream(file); // this will be used in reading the data from the internet InputStream inputStream = urlConnection.getInputStream(); // this is the total size of the file int totalSize = urlConnection.getContentLength(); // variable to store total downloaded bytes int downloadedSize = 0; // create a buffer... byte[] buffer = new byte[1024]; int bufferLength = 0; // used to store a temporary size of the buffer // now, read through the input buffer and write the contents to the file while ((bufferLength = inputStream.read(buffer)) > 0) { // add the data in the buffer to the file in the file output stream (the // file on the sd card fileOutput.write(buffer, 0, bufferLength); // add up the size so we know how much is downloaded downloadedSize += bufferLength; } // close the output stream when done fileOutput.close(); Uri path = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(path, "application/pdf"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); this.cordova.getActivity().startActivity(intent); // catch some possible errors... } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return ""; }
From source file:fr.simon.marquis.preferencesmanager.ui.PreferencesActivity.java
private void createShortcut() { Intent shortcutIntent = new Intent(this, PreferencesActivity.class); shortcutIntent.putExtra(EXTRA_PACKAGE_NAME, packageName); shortcutIntent.putExtra(EXTRA_TITLE, title); shortcutIntent.putExtra(EXTRA_SHORTCUT, true); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher)); addIntent.setAction(INSTALL_SHORTCUT); sendBroadcast(addIntent);/*from www .j a v a 2 s. co m*/ }
From source file:ca.mudar.snoozy.receiver.PowerConnectionReceiver.java
private void notify(Context context, boolean isConnectedPower, boolean hasVibration, boolean hasSound, int notifyCount) { final Resources res = context.getResources(); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_notify).setContentTitle(res.getString(R.string.notify_content_title)) .setAutoCancel(true);//w w w. j av a 2 s .co m if (notifyCount == 1) { final int resContentTextSingle = (isConnectedPower ? R.string.notify_content_text_single_on : R.string.notify_content_text_single_off); mBuilder.setContentText(res.getString(resContentTextSingle)); } else { mBuilder.setNumber(notifyCount).setContentText(res.getString(R.string.notify_content_text_multi)); } if (hasVibration && hasSound) { mBuilder.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND); } else if (hasVibration) { mBuilder.setDefaults(Notification.DEFAULT_VIBRATE); } else if (hasSound) { mBuilder.setDefaults(Notification.DEFAULT_SOUND); } // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(context, MainActivity.class); final Bundle extras = new Bundle(); extras.putBoolean(Const.IntentExtras.INCREMENT_NOTIFY_GROUP, true); extras.putBoolean(Const.IntentExtras.RESET_NOTIFY_NUMBER, true); resultIntent.putExtras(extras); resultIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mBuilder.setContentIntent( PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT)); Intent receiverIntent = new Intent(context, PowerConnectionReceiver.class); receiverIntent.setAction(Const.IntentActions.NOTIFY_DELETE); PendingIntent deleteIntent = PendingIntent.getBroadcast(context, Const.RequestCodes.RESET_NOTIFY_NUMBER, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setDeleteIntent(deleteIntent); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // NOTIFY_ID allows updates to the notification later on. mNotificationManager.notify(Const.NOTIFY_ID, mBuilder.build()); }
From source file:com.app.imagecreator.activities.HomeActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == FETCH_FROM_CAMERA_FULLVIEW && resultCode == RESULT_OK) { String path = getRealPathfromUri(outputFileUri); // Utility.log("ImgPath", path); Intent intent = new Intent(HomeActivity.this, FilterActivity.class); intent.putExtra(PATH, path);// w w w . j a va 2 s . c o m intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } else if (requestCode == FETCH_FROM_GALLERY && resultCode == RESULT_OK && null != data) { Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); picturePath = cursor.getString(columnIndex); cursor.close(); Intent intent = new Intent(HomeActivity.this, FilterActivity.class); intent.putExtra(PATH, picturePath); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } if (!billingProcessor.handleActivityResult(requestCode, resultCode, data)) super.onActivityResult(requestCode, resultCode, data); }
From source file:com.android.projectz.teamrocket.thebusapp.settings.SettingGeneralActivity.java
public void reload() { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);//from w ww . ja v a 2 s. co m }
From source file:com.insthub.O2OMobile.Activity.B0_SigninActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK) { if (isExit == false) { isExit = true;//from w ww .j a v a 2 s .c o m ToastView toast = new ToastView(getApplicationContext(), getString(R.string.exit_again)); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); handler.sendEmptyMessageDelayed(0, 3000); return true; } else { if (SESSION.getInstance().uid == 0) { finish(); } else { Intent intent = new Intent(this, SlidingActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } return false; } } return true; }
From source file:bander.notepad.Notepad.java
/** * Sets the theme for AppCompat. There is really no dark theme at the moment, it is mainly for * the Toolbar Color Chooser.//from w w w.ja va 2 s. co m * * @param activity ActionBarActivity acting as a Context * @param classType Launch a new activity. */ public static void setAppCompatThemeFromPreferences(ActionBarActivity activity, String classType) { SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(activity); if (mSettings.getString("themeType", "0").equals("0")) { final int abc = mSettings.getInt("actionBarColor", 0); /** * In case you are wondering, the random numbers are the 500 colors that show up with * black text from here: * {@link http://www.google.com/design/spec/style/color.html} * The black text means that I have to use a light theme. */ if (abc >= 11 && abc <= 15 || abc == 18) { mSettings.edit().putBoolean("darkAppCompatTheme", false).apply(); } else { mSettings.edit().putBoolean("darkAppCompatTheme", true).apply(); } } else { /** * Somehow, we ended up with the wrong theme, so let's launch the right activity. */ switch (classType) { case "Prefs": { Intent intent = new Intent(); intent.setClass(activity, PrefsActivity.class); activity.startActivity(intent); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); new PrefsActivityAppCompat().finish(); break; } case "Edit": { Intent intent = new Intent(); intent.setClass(activity, NoteEdit.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivity(intent); new NoteEditAppCompat().finish(); break; } case "NoteList": { Intent intent = new Intent(); intent.setClass(activity, NoteList.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivity(intent); new NoteListAppCompat().finish(); break; } default: { Intent intent = new Intent(); intent.setClass(activity, Notepad.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivity(intent); break; } } } }
From source file:com.arisprung.tailgate.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *//* w w w . j av a2 s. c om*/ private static void generateNotification(Context context, MessageBean message) { // Intent notificationIntent = new Intent(ctx, MainActivity.class); // PendingIntent contentIntent = PendingIntent.getActivity(ctx, // 10, notificationIntent, // PendingIntent.FLAG_CANCEL_CURRENT); // // NotificationManager nm = (NotificationManager) ctx // .getSystemService(Context.NOTIFICATION_SERVICE); // // Resources res = ctx.getResources(); // Notification.Builder builder = new Notification.Builder(ctx); // // Bitmap profile = TailGateUtility.getUserPic(message.getFaceID()); // // builder.setContentIntent(contentIntent) // .setSmallIcon(R.drawable.ic_launcher) // .setLargeIcon(profile) // .setTicker(res.getString(R.string.app_name)) // .setWhen(System.currentTimeMillis()) // .setAutoCancel(true) // .setContentTitle(message.getUserName()) // .setContentText(message.getMessage()); // Notification n = builder.build(); // // nm.notify(0, n); int icon = R.drawable.fanatic_icon_72px; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message.getMessage(), when); String name = message.getUserName(); Intent notificationIntent = new Intent(context, MainActivity.class); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, name, message.getMessage(), intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:br.com.android.cotuca.toptask.Activitys.MSimplesActivity.java
private void selectItem(int posicao) { FragmentManager fm = getFragmentManager(); if (posicao == 0) { Fragment f_tarefas = new FragmentTarefas(); if (idProjetoSelecionado != 0) { Bundle dadosProjeto = new Bundle(); dadosProjeto.putInt(ContratoProjetos.Colunas._ID, idProjetoSelecionado); f_tarefas.setArguments(dadosProjeto); }//from w w w. j av a2 s . c o m fm.beginTransaction().replace(R.id.content_frame, f_tarefas).commit(); } else if (posicao == 1) { if (!dao.getTarefasDoUsuarioNoProjetos(idProjetoSelecionado, idUsuarioSelecionado).isEmpty()) { Intent i = new Intent(this, GraficosActivity.class); Bundle dados = new Bundle(); dados.putInt(Tags.ID_PROJETO, idProjetoSelecionado); dados.putInt(Tags.ID_USUARIO, idUsuarioSelecionado); i.putExtras(dados); startActivity(i); } else { Log.i("lista de tarefas vazia", "lista de tarefas vazia"); Toast.makeText(getApplicationContext(), "Voce ainda nao possui tarefas", Toast.LENGTH_SHORT).show(); } } else if (posicao == 2) { Intent iSairProjetoAtual = new Intent(this, ProjetosActivity.class); Bundle dados = new Bundle(); dados.putInt(Tags.ID_USUARIO, idUsuarioSelecionado); iSairProjetoAtual.putExtras(dados); iSairProjetoAtual.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(iSairProjetoAtual); } mDrawerList.setItemChecked(posicao, true); setTitle(mPaginaTitulo[posicao]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.auth0.sample.ProfileActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); shares = getSharedPreferences("USER", 0); editor = shares.edit();//from w w w.j a v a2 s . c o m profile = getIntent().getParcelableExtra(Lock.AUTHENTICATION_ACTION_PROFILE_PARAMETER); access_token = getIntent().getParcelableExtra(Lock.AUTHENTICATION_ACTION_TOKEN_PARAMETER); Log.e("Access_Token", access_token.getAccessToken()); editor.putString("ACCESS_TOKEN", access_token.getAccessToken()); editor.commit(); client = new AsyncHttpClient(); app = (SampleApplication) getApplication(); toolbar = (Toolbar) findViewById(R.id.toolbar); create = (TextView) toolbar.findViewById(R.id.create_tweet); create.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { createTweet(ProfileActivity.this); } }); navigationView = (NavigationView) findViewById(R.id.navigation_view); header = navigationView.inflateHeaderView(R.layout.header); username = (TextView) header.findViewById(R.id.username); proPic = (ImageView) header.findViewById(R.id.profile_image); ((TextView) header.findViewById(R.id.email)).setText(profile.getEmail()); /* client.get(((HashMap) profile.getExtraInfo().get("cover")).get("source").toString(), new FileAsyncHttpResponseHandler(ProfileActivity.this.getApplicationContext()) { @Override public void onFailure(int statusCode, cz.msebera.android.httpclient.Header[] headers, Throwable throwable, File file) { } @Override public void onSuccess(int statusCode, cz.msebera.android.httpclient.Header[] headers, final File response) { ProfileActivity.this.runOnUiThread(new Runnable() { @Override public void run() { Bitmap image = BitmapFactory.decodeFile(response.getPath()); } }); } }); */ username.setText(profile.getName()); if (profile.getPictureURL() != null) { ImageLoader.getInstance().displayImage(profile.getPictureURL(), proPic); } navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { // This method will trigger on item Click of navigation menu @Override public boolean onNavigationItemSelected(MenuItem menuItem) { //Checking if the item is in checked state or not, if not make it in checked state nav = true; menuItem.setChecked(false); //Closing drawer on item click drawerLayout.closeDrawers(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Fragment fragment; //Check to see which item was being clicked and perform appropriate action switch (menuItem.getItemId()) { case R.id.log_out: editor.remove("ENDPOINT_URL").remove("ACCESS_TOKEN").commit(); Intent intent = getApplicationContext().getPackageManager() .getLaunchIntentForPackage(getApplicationContext().getPackageName()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); default: Toast.makeText(getApplicationContext(), "Somethings Wrong", Toast.LENGTH_SHORT).show(); break; } return false; } }); // Initializing Drawer Layout and ActionBarToggle drawerLayout = (DrawerLayout) findViewById(R.id.drawer); ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, (Toolbar) toolbar, R.string.openDrawer, R.string.closeDrawer) { @Override public void onDrawerClosed(View drawerView) { // Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank super.onDrawerClosed(drawerView); drawerLayout.setSelected(false); } @Override public void onDrawerOpened(View drawerView) { // Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank super.onDrawerOpened(drawerView); } }; //Setting the actionbarToggle to drawer layout drawerLayout.setDrawerListener(actionBarDrawerToggle); //calling sync state is necessay or else your hamburger icon wont show up actionBarDrawerToggle.syncState(); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); final LinearLayoutManager layoutManager = new LinearLayoutManager(ProfileActivity.this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.setLayoutManager(layoutManager); mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view); // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView mRecyclerView.setHasFixedSize(true); // use a linear layout manager mRecyclerView.setLayoutManager(layoutManager); items = new ArrayList<Tweet>(); try { items.add(new Tweet(new JSONObject("{\n" + " \"id\": \"f808d40b-4c54-4824-b3e0-8217e0840067\",\n" + " \"type\": \"tweets\",\n" + " \"attributes\": {\n" + " \"author\": \"Tang Rufus\",\n" + " \"body\": \"Hi all\",\n" + " \"created-at\": \"2015-02-17T01:28:32.402Z\"\n" + " }\n" + " }"))); } catch (JSONException e) { e.printStackTrace(); } // specify an adapter (see also next example) mAdapter = new TweetAdapter(items); mRecyclerView.setAdapter(mAdapter); setEndpointURL(this); refresh_handler = new Handler(); refresh_runnable = new Runnable() { @Override public void run() { if (!refresh) { ProfileActivity.this.get(); refresh_handler.postDelayed(this, 50000); refresh = true; } } }; }