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.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
@Override public void onBackPressed() { super.onBackPressed(); if (CommonURL.USER_TYPE == 1) { Intent intent = new Intent(this, SellerDetail.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);// w w w .j a v a2 s . com } else { Intent intent = new Intent(this, UserDetail.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }
From source file:app.sunstreak.yourpisd.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Pass the event to ActionBarDrawerToggle, if it returns // true, then it has handled the app icon touch event if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }/*from w w w . j a v a2 s. c om*/ // Handle your other action bar items... // Handle item selection switch (item.getItemId()) { case R.id.log_out: session = null; // attendanceTask.cancel(true); // attendanceTask = null; Editor editor = getSharedPreferences("LoginActivity", Context.MODE_PRIVATE).edit(); editor.putBoolean("auto_login", false); editor.commit(); Intent intent = new Intent(this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("show", true); startActivity(intent); return true; case R.id.credits: Intent intentCred1 = new Intent(this, CreditActivity.class); startActivity(intentCred1); return true; // case R.id.refresh: // dg.clearData(); // Intent intentR = new Intent(this, LoginActivity.class); // intentR.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // intentR.putExtra("Refresh", true); // startActivity(intentR); default: return super.onOptionsItemSelected(item); } }
From source file:net.openid.appauthdemo.TokenActivity.java
@MainThread private void signOut() { // discard the authorization and token state, but retain the configuration and // dynamic client registration (if applicable), to save from retrieving them again. AuthState currentState = mStateManager.getCurrent(); AuthState clearedState = new AuthState(currentState.getAuthorizationServiceConfiguration()); if (currentState.getLastRegistrationResponse() != null) { clearedState.update(currentState.getLastRegistrationResponse()); }// w w w. ja v a2s . co m mStateManager.replace(clearedState); Intent mainIntent = new Intent(this, LoginActivity.class); mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(mainIntent); finish(); }
From source file:at.alladin.rmbt.android.test.RMBTLoopService.java
private NotificationCompat.Builder createNotificationBuilder() { final Resources res = getResources(); Intent notificationIntent = new Intent(getApplicationContext(), RMBTMainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent openAppIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0); final NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.stat_icon_loop) .setContentTitle(res.getText(R.string.loop_notification_title)) .setTicker(res.getText(R.string.loop_notification_ticker)).setContentIntent(openAppIntent); setNotificationText(builder);/*from w w w.j ava 2 s. c o m*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (SHOW_DEV_BUTTONS) { final Intent stopIntent = new Intent(ACTION_STOP, null, getApplicationContext(), getClass()); final PendingIntent stopPIntent = PendingIntent.getService(getApplicationContext(), 0, stopIntent, 0); final Intent forceIntent = new Intent(ACTION_FORCE, null, getApplicationContext(), getClass()); final PendingIntent forcePIntent = PendingIntent.getService(getApplicationContext(), 0, forceIntent, 0); addActionToNotificationBuilder(builder, stopPIntent, forcePIntent); } } return builder; }
From source file:com.njlabs.amrita.aid.aums.AumsActivity.java
private void exitAums() { if (isLoggedIn) { if (backPressTime + 2000 > System.currentTimeMillis()) { toast.cancel();/*ww w . j a va2s .c om*/ aums.logout(); Toast.makeText(getApplicationContext(), "You have successfully logged out.", Toast.LENGTH_LONG) .show(); Intent intent = new Intent(baseContext, Landing.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } else { toast = Toast.makeText(getBaseContext(), "Press once again to Log Out of AUMS.", Toast.LENGTH_SHORT); toast.show(); } backPressTime = System.currentTimeMillis(); } else { Intent intent = new Intent(baseContext, Landing.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }
From source file:io.coldstart.android.GCMIntentService.java
private void SendCombinedNotification(String EventCount) { Notification notification = new Notification(R.drawable.ic_stat_alert, EventCount + " new SNMP Traps!", System.currentTimeMillis()); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.defaults |= Notification.DEFAULT_VIBRATE; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0xffff0000;/*from w ww .ja v a2 s .c om*/ notification.ledOnMS = 300; notification.ledOffMS = 1000; notification.defaults |= Notification.DEFAULT_SOUND; Context context = getApplicationContext(); Intent notificationIntent = new Intent(this, TrapListActivity.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); notificationIntent.putExtra("forceRefresh", true); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, EventCount + " SNMP Traps", "Click to launch ColdStart.io", contentIntent); mNM.notify(43523, notification);//NotificationID++ }
From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java
private void exitGpms() { if (loggedIn) { if (backPress + 2000 > System.currentTimeMillis()) { toast.cancel();// w w w. ja va2 s. co m gpms.logout(); Toast.makeText(getApplicationContext(), "You have successfully logged out.", Toast.LENGTH_LONG) .show(); Intent intent = new Intent(baseContext, Landing.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } else { toast = Toast.makeText(getBaseContext(), "Press once again to Log Out of GPMS.", Toast.LENGTH_SHORT); toast.show(); } backPress = System.currentTimeMillis(); } else { Intent intent = new Intent(baseContext, Landing.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }
From source file:sjizl.com.ChatActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (CommonUtilities.isInternetAvailable(getApplicationContext())) //returns true if internet available {// w w w. ja v a 2s . com SharedPreferences sp = getApplicationContext().getSharedPreferences("loginSaved", Context.MODE_PRIVATE); pid = sp.getString("pid", null); naam = sp.getString("naam", null); username = sp.getString("username", null); password = sp.getString("password", null); foto = sp.getString("foto", null); foto_num = sp.getString("foto_num", null); Bundle bundle = getIntent().getExtras(); pid_user = bundle.getString("pid_user"); user = bundle.getString("user"); user_foto_num = bundle.getString("user_foto_num"); user_foto = bundle.getString("user_foto"); // Toast.makeText(getApplicationContext(), "pid_user"+pid_user, Toast.LENGTH_SHORT).show(); if (user.equalsIgnoreCase(naam.toString())) { Toast.makeText(getApplicationContext(), "You can't message yourself!", Toast.LENGTH_SHORT).show(); finish(); } AbsListViewBaseActivity.imageLoader.init(ImageLoaderConfiguration.createDefault(getBaseContext())); //registerReceiver(mHandleMessageReceiver2, new IntentFilter(DISPLAY_MESSAGE_ACTION)); setContentView(R.layout.activity_chat); imageLoader.loadImage("https://www.sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto + "", new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { d1 = new BitmapDrawable(getResources(), loadedImage); } }); imageLoader.loadImage("https://www.sjizl.com/fotos/" + foto_num + "/thumbs/" + foto + "", new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { d2 = new BitmapDrawable(getResources(), loadedImage); } }); smilbtn = (ImageView) findViewById(R.id.smilbtn); listView = (ListView) findViewById(android.R.id.list); underlayout = (LinearLayout) findViewById(R.id.underlayout); smiles_layout = (LinearLayout) findViewById(R.id.smiles); textView1_bgtext = (TextView) findViewById(R.id.textView1_bgtext); textView1_bgtext.setText(user); imageView2_dashboard = (ImageView) findViewById(R.id.imageView2_dashboard); imageView1_logo = (ImageView) findViewById(R.id.imageView1_logo); imageView_bericht = (ImageView) findViewById(R.id.imageView_bericht); textView2_under_title = (TextView) findViewById(R.id.textView2_under_title); right_lin = (LinearLayout) findViewById(R.id.right_lin); left_lin1 = (LinearLayout) findViewById(R.id.left_lin1); left_lin3 = (LinearLayout) findViewById(R.id.left_lin3); left_lin4 = (LinearLayout) findViewById(R.id.left_lin4); middle_lin = (LinearLayout) findViewById(R.id.middle_lin); smile_lin = (LinearLayout) findViewById(R.id.smile_lin); ber_lin = (LinearLayout) findViewById(R.id.ber_lin); progressBar_hole = (ProgressBar) findViewById(R.id.progressBar_hole); progressBar_hole.setVisibility(View.INVISIBLE); imageLoader.displayImage("http://sjizl.com/fotos/" + user_foto_num + "/thumbs/" + user_foto, imageView2_dashboard, options); new UpdateChat().execute(); mNewMessage = (EditText) findViewById(R.id.newmsg); ber_lin = (LinearLayout) findViewById(R.id.ber_lin); photosend = (ImageView) findViewById(R.id.photosend); /* if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { imageLoader.loadImage("http://sjizl.com/fotos/"+user_foto_num+"/thumbs/"+user_foto, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { super.onLoadingComplete(imageUri, view, loadedImage); Bitmap LoadedImage2 = loadedImage; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { if(loadedImage!=null){ LoadedImage2 = CommonUtilities.fastblur16(loadedImage, 4,getApplicationContext()); } } if (Build.VERSION.SDK_INT >= 16) { listView.setBackground(new BitmapDrawable(getApplicationContext().getResources(), LoadedImage2)); } else { listView.setBackgroundDrawable(new BitmapDrawable(LoadedImage2)); } } } ); } */ final ImageView left_button; left_button = (ImageView) findViewById(R.id.imageView1_back); CommonUtilities u = new CommonUtilities(); u.setHeaderConrols(getApplicationContext(), this, right_lin, left_lin3, left_lin4, left_lin1, left_button); listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { mScrollState = scrollState; } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); listView.setLongClickable(true); registerForContextMenu(listView); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); viewPager_smiles = new ViewPager(this); viewPager_smiles.setId(0x1000); LayoutParams layoutParams555 = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParams555.width = LayoutParams.MATCH_PARENT; layoutParams555.height = (metrics.heightPixels / 2); viewPager_smiles.setLayoutParams(layoutParams555); TabsPagerAdapter mAdapter = new TabsPagerAdapter(getSupportFragmentManager(), mNewMessage); viewPager_smiles.setAdapter(mAdapter); LayoutInflater inflater = null; viewPager_smiles.setVisibility(View.VISIBLE); smiles_layout.addView(viewPager_smiles); smiles_layout.setVisibility(View.GONE); left_lin4.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { Intent profile = new Intent(getApplicationContext(), ProfileActivityMain.class); profile.putExtra("user", user); profile.putExtra("user_foto", user_foto); profile.putExtra("user_foto_num", user_foto_num); profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(profile); } return false; } }); middle_lin.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { Intent profile = new Intent(getApplicationContext(), ProfileActivityMain.class); profile.putExtra("user", user); profile.putExtra("user_foto", user_foto); profile.putExtra("user_foto_num", user_foto_num); profile.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(profile); } return false; } }); smile_lin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { opensmiles(); } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent dashboard = new Intent(getApplicationContext(), ProfileActivityMain.class); dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); dashboard.putExtra("user", ArrChatLines.get(position).getNaam()); dashboard.putExtra("user_foto", foto); dashboard.putExtra("user_foto_num", foto_num); startActivity(dashboard); } }); mNewMessage.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { v.setFocusable(true); v.setFocusableInTouchMode(true); smiles_layout.setVisibility(View.GONE); smilbtn.setImageResource(R.drawable.emoji_btn_normal); return false; } return false; } }); TextWatcher textWatcher = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { //after text changed } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (ArrChatLines.get(0).getblocked_profile().equals("1")) { } else if (ArrChatLines.get(0).getblocked_profile2().equals("1")) { } else { CommonUtilities.startandsendwebsock( "" + pid_user + " " + naam + " " + pid + " is typing to you ..."); } } @Override public void afterTextChanged(Editable s) { /* AsyncHttpClient.getDefaultInstance().websocket("ws://sjizl.com:9300", "my-protocol", new WebSocketConnectCallback() { @Override public void onCompleted(Exception ex, WebSocket webSocket) { if (ex != null) { ex.printStackTrace(); return; } webSocket.send(""+pid_user+" "+naam+" "+pid+" is typing to you ..."); webSocket.close(); } }); */ } }; photosend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ArrChatLines.get(0).getblocked_profile().equals("1")) { } else if (ArrChatLines.get(0).getblocked_profile2().equals("1")) { } else { openGallery(SELECT_FILE1); } } }); mNewMessage.addTextChangedListener(textWatcher); ber_lin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { SpannableStringBuilder spanStr = (SpannableStringBuilder) mNewMessage.getText(); Spanned cs = (Spanned) mNewMessage.getText(); String a = Html.toHtml(spanStr); String text = mNewMessage.getText().toString(); mNewMessage.setText(""); mNewMessage.requestFocus(); mybmp2 = "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto; if (text.length() < 1) { } else { addItem(foto, foto_num, "0", naam, text.toString(), "http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto, "", a); } } }); hideSoftKeyboard(); } else { Intent dashboard = new Intent(getApplicationContext(), NoInternetActivity.class); dashboard.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(dashboard); finish(); } mNewMessage.clearFocus(); listView.requestFocus(); final String wsuri = "ws://sjizl.com:9300"; WebSocketConnection mConnection8 = new WebSocketConnection(); if (mConnection8.isConnected()) { mConnection8.reconnect(); } else { try { mConnection8.connect(wsuri, new WebSocketConnectionHandler() { @Override public void onOpen() { Log.d("TAG", "Status: Connected to " + wsuri); } @Override public void onTextMessage(String payload) { if (payload.contains("message send")) { String[] parts = payload.split(" "); String zender = parts[0]; String send_from = parts[1]; String send_name = parts[2]; String send_foto = parts[3]; String send_foto_num = parts[4]; String send_xxx = parts[5]; // Toast.makeText(getApplication(), "" + "\n zender: "+zender+"" + "\n pid_user: "+pid_user+"" +"\n pid: "+pid+"" + // "\n send_from: "+send_from, // Toast.LENGTH_LONG).show(); if (zender.equalsIgnoreCase(pid) || zender.equalsIgnoreCase(pid_user)) { if (send_from.equalsIgnoreCase(pid_user) || send_from.equalsIgnoreCase(pid)) { //Toast.makeText(getApplication(), "uu", Toast.LENGTH_LONG).show(); new UpdateChat().execute(); } } } else if (payload.contains("is typing to you")) { String[] parts = payload.split(" "); String part1 = parts[0]; // 004 is_typing_name = parts[1]; // 034556 if (is_typing_name.equalsIgnoreCase(user)) { if (ArrChatLines.size() > 0) { oldvalue = ArrChatLines.get(0).getLaatstOnline(); } else { oldvalue = textView2_under_title.getText().toString(); } Timer t = new Timer(false); t.schedule(new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { public void run() { textView2_under_title.setText("typing ..."); } }); } }, 2); Timer t2 = new Timer(false); t2.schedule(new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { public void run() { textView2_under_title.setText(oldvalue); } }); } }, 2000); } } Log.d("TAG", "Got echo: " + payload); } @Override public void onClose(int code, String reason) { Log.d("TAG", "Connection lost."); } }); } catch (WebSocketException e) { Log.d("TAG", e.toString()); } } }
From source file:org.safegees.safegees.gui.view.MainActivity.java
private void setPermissionsAlertDialog(String message) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(message).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage(getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i);/* w w w . j a v a 2 s . co m*/ //finish(); } }).setNegativeButton("EXIT", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.wso2.iot.agent.services.MessageProcessor.java
@SuppressWarnings("unused") @Override//w w w .java 2s .com public void onReceiveAPIResult(Map<String, String> result, int requestCode) { String responseStatus; String response; if (requestCode == Constants.NOTIFICATION_REQUEST_CODE) { Preference.putLong(context, Constants.PreferenceFlag.LAST_SERVER_CALL, CommonUtils.currentDate().getTime()); Intent intent = new Intent(); intent.setAction(Constants.SYNC_BROADCAST_ACTION); context.sendBroadcast(intent); if (isWipeTriggered) { if (Constants.SYSTEM_APP_ENABLED) { CommonUtils.callSystemApp(context, Constants.Operation.WIPE_DATA, null, null); } else { Log.i(TAG, "Not the device owner."); } } if (isEnterpriseWipeTriggered) { CommonUtils.disableAdmin(context); Intent intentEnterpriseWipe = new Intent(context, ServerConfigsActivity.class); intentEnterpriseWipe.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentEnterpriseWipe.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intentEnterpriseWipe); if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "Started enterprise wipe"); } } if (isRebootTriggered) { CommonUtils.callSystemApp(context, Constants.Operation.REBOOT, null, null); } if (isUpgradeTriggered) { String schedule = Preference.getString(context, context.getResources().getString(R.string.pref_key_schedule)); CommonUtils.callSystemApp(context, Constants.Operation.UPGRADE_FIRMWARE, schedule, null); } if (isShellCommandTriggered && shellCommand != null) { CommonUtils.callSystemApp(context, Constants.Operation.EXECUTE_SHELL_COMMAND, shellCommand, null); } if (result != null) { responseStatus = result.get(Constants.STATUS_KEY); response = result.get(Constants.RESPONSE); if (Constants.Status.SUCCESSFUL.equals(responseStatus) || Constants.Status.CREATED.equals(responseStatus)) { if (response != null && !response.isEmpty()) { if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "Pending Operations List: " + response); } if (Constants.DEFAULT_OWNERSHIP.equals(Constants.OWNERSHIP_COSU)) { if (!Preference.getBoolean(context, Constants.PreferenceFlag.DEVICE_INITIALIZED)) { Preference.putBoolean(context, Constants.PreferenceFlag.DEVICE_INITIALIZED, true); } } performOperation(response); } } else if (Constants.Status.AUTHENTICATION_FAILED.equals(responseStatus) && org.wso2.iot.agent.proxy.utils.Constants.REFRESH_TOKEN_EXPIRED.equals(response)) { Log.d(TAG, "Requesting credentials to obtain new token pair."); LocalNotification.stopPolling(context); Preference.putBoolean(context, Constants.TOKEN_EXPIRED, true); CommonUtils.displayNotification(context, R.drawable.ic_error_outline_white_24dp, context.getResources().getString(R.string.title_need_to_sign_in), context.getResources().getString(R.string.msg_need_to_sign_in), AuthenticationActivity.class, Constants.TOKEN_EXPIRED, Constants.SIGN_IN_NOTIFICATION_ID); } } } }