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:de.nico.asura.Main.java
private void setList() { ListView list = (ListView) findViewById(R.id.listView_main); ListAdapter adapter = new SimpleAdapter(this, downloadList, android.R.layout.simple_list_item_1, new String[] { TAG_NAME }, new int[] { android.R.id.text1 }); list.setAdapter(adapter);/*from ww w .j a v a 2 s . c o m*/ // Do nothing when there is no Internet if (!(Utils.isNetworkAvailable(this))) { return; } // React when user click on item in the list list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int pos, long id) { Uri downloadUri = Uri.parse(downloadList.get(pos).get(TAG_URL)); String title = downloadList.get(pos).get(TAG_NAME); file = new File(Environment.getExternalStorageDirectory() + "/" + localLoc + "/" + downloadList.get(pos).get(TAG_FILENAME) + ".pdf"); Uri dest = Uri.fromFile(file); if (file.exists()) { Intent pdfIntent = new Intent(Intent.ACTION_VIEW); pdfIntent.setDataAndType(dest, "application/pdf"); pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); try { startActivity(pdfIntent); } catch (ActivityNotFoundException e) { Utils.makeLongToast(Main.this, noPDF); Log.e("ActivityNotFoundException", e.toString()); } return; } // Download PDF Request request = new Request(downloadUri); request.setTitle(title).setDestinationUri(dest); downloadID = downloadManager.enqueue(request); } }); }
From source file:com.notifry.android.ChooseAccount.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Intent intent = new Intent(this, Notifry.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);/* ww w. j a v a 2 s. co m*/ return true; case REFRESH_IDS: // Dispatch this to the updater service. Intent intentData = new Intent(getBaseContext(), UpdaterService.class); intentData.putExtra("type", "registration"); intentData.putExtra("registration", C2DMessaging.getRegistrationId(this)); startService(intentData); Toast.makeText(thisActivity, getString(R.string.background_refreshing), Toast.LENGTH_SHORT).show(); return true; } return super.onOptionsItemSelected(item); }
From source file:git.lawpavilionprime.auth._Login.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login_);/*from www . ja v a2 s.c om*/ mContext = _Login.this; txtEmail = (TextView) findViewById(R.id.email); txtPassword = (TextView) findViewById(R.id.password); btnLogin = (Button) findViewById(R.id.login); ckRememberMe = (CheckBox) findViewById(R.id.checkbox); txtForgotPassword = (TextView) findViewById(R.id.forgotPassword); txtSignUp = (TextView) findViewById(R.id.signUp); btnSignUp = (Button) findViewById(R.id.btnSignUp); validator = new Validator(); config = new Config(_Login.this); dbAdapter = new UserDBAdapter(this); mProgressBar = (LinearLayout) findViewById(R.id.progressMum); txtProgressMessage = (TextView) findViewById(R.id.progressMessage); btnBkStore = (Button) findViewById(R.id.btnBkStore); baseUrl = "http://lawpavilionstore.com/android/login"; dbAdapter.open(DB_NAME); dbAdapter.createUserTable(); Cursor cursor = dbAdapter.fetch("SELECT * from " + dbAdapter.TABLE_NAME + " limit 1"); if (cursor != null) { //new user if (cursor.getCount() == 1) { String loggedOut = cursor.getString(cursor.getColumnIndex(dbAdapter.LOG_OUT)); if (loggedOut.equalsIgnoreCase("0")) { //User not looged out..continue String token = cursor.getString(cursor.getColumnIndex(dbAdapter.TOKEN)); Toast.makeText(_Login.this, "Existing", Toast.LENGTH_SHORT).show(); String set_up_status = cursor.getString(cursor.getColumnIndex(dbAdapter.SET_UP_STATUS)); if (set_up_status.equalsIgnoreCase("pending")) { Intent intent = new Intent(_Login.this, _Module.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); //TODO: remove this //dbAdapter.executeQuery("DROP TABLE " + dbAdapter.TABLE_NAME + ";"); _Login.this.finish(); } else { Intent intent = new Intent(_Login.this, Dashboard.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); //TODO: remove this //dbAdapter.executeQuery("DROP TABLE " + dbAdapter.TABLE_NAME + ";"); _Login.this.finish(); } } else { //user has been forced to login.. //check if gcm exist for user.. SIGN_IN_TYPE = LOGGED_OUT_USER_TYPE; } } else { //try register GCM for new user Log.d("---LOG---", "GCM started"); new RegisterApp(getApplicationContext()).execute(); //New user account.. SIGN_IN_TYPE = NEW_USER_TYPE; } cursor.close(); } else { Toast.makeText(_Login.this, "DB error", Toast.LENGTH_SHORT).show(); _Login.this.finish(); //Do something here } dbAdapter.close(); btnLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { _email = txtEmail.getText().toString().trim(); _password = txtPassword.getText().toString().trim(); boolean isFieldSet = true; if (!validator.isValidEmail(_email)) { txtEmail.setError(Validator.emailErrorMessage); isFieldSet = false; } if (validator.isEmpty(_password)) { txtPassword.setError(Validator.defaultErrorMessage); isFieldSet = false; } //Toast.makeText(_Login.this, "Ready for Async Task", Toast.LENGTH_SHORT).show(); if (isFieldSet) { connectIfInternetIsAvailable(); } else { return; } } }); txtForgotPassword.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(_Login.this, _ForgotPassword.class); startActivity(intent); } }); btnSignUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(_Login.this, _SignUp.class); startActivity(intent); } }); // txtSignUp.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // // Intent intent = new Intent(_Login.this, _SignUp.class); // startActivity(intent); // } // }); btnBkStore.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(_Login.this, BookStore.class); startActivity(intent); } }); mProgressBar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //no action } }); }
From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.services.SystemMonitor.java
private int systemNotice() { int t = START_STICKY; Log.e(SystemMonitor.class.getSimpleName(), "call me redundant BABY! onStartCommand service"); int myID = android.os.Process.myPid(); // The intent to launch when the user clicks the expanded notification Intent intent = new Intent(this, MyHealthHubWithFragments.class); // Intent intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0); Notification notice = new Notification.Builder(getApplicationContext()).setSmallIcon(R.drawable.ic_launcher) .setWhen(System.currentTimeMillis()).setContentTitle(getPackageName()) .setContentText("System Monitor running").setContentIntent(pendIntent).getNotification(); notice.flags |= Notification.FLAG_AUTO_CANCEL; NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(myID, notice); return t;//from w ww . ja va 2 s.c o m }
From source file:c.neo.placas_validator.LicenseDataActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Log.d(TAG, "HOME BUTTON SELECTED"); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); // app icon in action bar clicked; go home Intent intent = new Intent(this, MainActivity.class); intent.putExtra("PLACA_NO", licenseID); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);//w w w.j av a2 s . c om //slidingPaneLayout.openPane(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.arifin.taxi.penumpang.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *///from w w w . j a v a 2s . c om private void generateNotification(Context context, String message) { // System.out.println("this is message " + message); // System.out.println("NOTIFICATION RECEIVED!!!!!!!!!!!!!!" + message); int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, MainDrawerActivity.class); notificationIntent.putExtra("fromNotification", "notification"); // 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, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); notification = builder.setContentIntent(intent).setSmallIcon(icon).setTicker(message).setWhen(when) .setAutoCancel(true).setContentTitle(title).setContentText(message).build(); // mNM.notify(NOTIFICATION, notification); /*notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL;*/ System.out.println("notification====>" + message); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; // notification.defaults |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0x00000000; notification.ledOnMS = 0; notification.ledOffMS = 0; notificationManager.notify(0, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "WakeLock"); wakeLock.acquire(); wakeLock.release(); }
From source file:com.cssweb.android.common.FairyUI.java
public static Intent genIntent(int paramInt1, String paramString1, String paramString2, String paramString3, Context paramContext) {//from w w w .j a v a 2 s . co m Intent localIntent = new Intent(); // localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); localIntent.putExtra("exchange", paramString1); localIntent.putExtra("stockcode", paramString2); localIntent.putExtra("stockname", paramString3); switch (paramInt1) { case Global.QUOTE_KLINE: localIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (CssSystem.getSDKVersionNumber() == 4) localIntent.setClass(paramContext, KLine2Activity.class); else localIntent.setClass(paramContext, KLineActivity.class); break; case Global.QUOTE_F10: if ("hk".equals(paramString1)) { StringBuffer sb = new StringBuffer(); sb.append(Config.roadf10); sb.append("hkf10/mobile/index.jsp?stockcode="); sb.append(paramString1); sb.append(paramString2); localIntent.putExtra("url", sb.toString()); localIntent.setClass(paramContext, WebViewDisplay.class); } else if ("cf".equals(paramString1) || "dc".equals(paramString1) || "sf".equals(paramString1) || "cz".equals(paramString1)) { StringBuffer sb = new StringBuffer(); sb.append(Config.roadf10); sb.append("hkf10/front/tbobject3511/indexM.jsp?stockcode="); sb.append(paramString1); sb.append(paramString2); localIntent.putExtra("url", sb.toString()); localIntent.setClass(paramContext, WebViewDisplay.class); } else { StringBuffer sb = new StringBuffer(); sb.append(Config.roadZixun); sb.append("iphone/f10/index_forword.jsp?code="); sb.append(paramString1); sb.append(paramString2); localIntent.putExtra("url", sb.toString()); localIntent.setClass(paramContext, WebViewDisplay.class); //localIntent.setClass(paramContext, GetF10List.class); } break; case Global.QUOTE_FENSHI: localIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); localIntent.setClass(paramContext, TrendActivity.class); break; case Global.QUOTE_BAOJIA: localIntent.setClass(paramContext, QuotePrice.class); break; case Global.QUOTE_MINGXI: localIntent.setClass(paramContext, QuoteDetail.class); break; case Global.QUOTE_FLINE: localIntent.setClass(paramContext, FLineActivity.class); break; case Global.QUOTE_USERSTK: localIntent.putExtra("requestType", 1); localIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); localIntent.setClass(paramContext, PersonalStock.class); break; case Global.QUOTE_WARN: localIntent.putExtra("requestType", 1); localIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); localIntent.setClass(paramContext, QuoteSet.class); break; default: localIntent.setClass(paramContext, TrendActivity.class); break; } return localIntent; }
From source file:net.frygo.findmybuddy.GCMIntentService.java
private static void generateAcceptfriendNotification(Context context, String message, String status) { Random rand = new Random(); int x = rand.nextInt(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, customlistview.class); if (status.equalsIgnoreCase("accept")) message = message + " added you as buddy"; else//w ww .ja v a2s.c o m message = message + " rejected you as buddy"; PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = new Notification(R.drawable.logo, message, System.currentTimeMillis()); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(x, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock mWakelock = pm .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, title); mWakelock.acquire(); // Timer before putting Android Device to sleep mode. Timer timer = new Timer(); TimerTask task = new TimerTask() { public void run() { mWakelock.release(); } }; timer.schedule(task, 5000); }
From source file:com.campusconnect.GoogleSignInActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_google); rootView = (LinearLayout) findViewById(R.id.main_layout); BitmapFactory.Options bm_opts = new BitmapFactory.Options(); bm_opts.inScaled = false;//from ww w . jav a 2s . c om Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.default_portrait_two, bm_opts); BitmapDrawable background = new BitmapDrawable(bitmap); rootView.setBackground(background); iv_branchProfileImage = (ImageView) findViewById(R.id.branch_profile_image); tv_branchUserName = (TextView) findViewById(R.id.branch_tv_username); try { String photourl = Branch.getInstance().getLatestReferringParams().getString("photourl"); if (photourl.isEmpty()) { iv_branchProfileImage.setImageResource(R.mipmap.ccnoti); } else { Picasso.with(GoogleSignInActivity.this).load(photourl).error(R.mipmap.ic_launcher) .memoryPolicy(MemoryPolicy.NO_CACHE).networkPolicy(NetworkPolicy.NO_CACHE) .placeholder(R.mipmap.ccnoti).into(iv_branchProfileImage); } tv_branchUserName.setText(Branch.getInstance().getLatestReferringParams().getString("profileName") + " " + "is Waiting For You"); iv_branchProfileImage.setVisibility(View.VISIBLE); tv_branchUserName.setVisibility(View.VISIBLE); } catch (JSONException e) { e.printStackTrace(); } if (!getIntent().hasExtra("logout")) { if (getSharedPreferences("CC", MODE_PRIVATE).contains("profileId")) { Intent home = new Intent(GoogleSignInActivity.this, HomeActivity2.class); home.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(home); finish(); } } firebaseAnalytics = FirebaseAnalytics.getInstance(this); // Views // mStatusTextView = (TextView) findViewById(R.id.status); // mDetailTextView = (TextView) findViewById(R.id.detail); // Button listeners findViewById(R.id.sign_in_button).setOnClickListener(this); findViewById(R.id.sign_out_button).setOnClickListener(this); findViewById(R.id.disconnect_button).setOnClickListener(this); // [START config_signin] // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build(); // [END config_signin] mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build(); // [START initialize_auth] mAuth = FirebaseAuth.getInstance(); // [END initialize_auth] // [START auth_state_listener] mAuthListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser user = firebaseAuth.getCurrentUser(); if (user != null) { // User is signed in Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid()); } else { // User is signed out Log.d(TAG, "onAuthStateChanged:signed_out"); } // [START_EXCLUDE] updateUI(user); // [END_EXCLUDE] } }; // [END auth_state_listener] }
From source file:com.getmarco.weatherstationviewer.gcm.StationGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w ww . j a v a 2 s . c o m */ private void sendNotification(String message) { Intent intent = new Intent(this, StationListActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Station update").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }