List of usage examples for android.content Intent setFlags
public @NonNull Intent setFlags(@Flags int flags)
From source file:com.msted.lensrocket.LensRocketService.java
public void logout(boolean shouldRedirectToLogin) { //Clear values mFriendNames.clear();//www .ja v a2 s . com mFriends.clear(); mRockets.clear(); //Clear the cookies so they won't auto login to a provider again CookieSyncManager.createInstance(mContext); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); //Clear the user id and token from the shared preferences SharedPreferences settings = mContext.getSharedPreferences("UserData", 0); SharedPreferences.Editor preferencesEditor = settings.edit(); preferencesEditor.clear(); preferencesEditor.commit(); //Clear settings shared preferences SharedPreferences settingsPrefs = PreferenceManager.getDefaultSharedPreferences(mContext); if (settingsPrefs != null) { preferencesEditor = settingsPrefs.edit(); preferencesEditor.clear(); preferencesEditor.commit(); } mClient.logout(); //Take the user back to the splash screen activity to relogin if requested if (shouldRedirectToLogin) { Intent logoutIntent = new Intent(mContext, SplashScreenActivity.class); logoutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(logoutIntent); } }
From source file:com.example.gemswin.screencastrecevertest.MainActivity_Reciever.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_reciever); WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE); String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); TextView text = (TextView) findViewById(R.id.textView); planetList = new ArrayList<String>(); mTextureView = (TextureView)findViewById(R.id.textureView); mTextureView.setSurfaceTextureListener(this); mTextureView.requestLayout();/*from ww w. j a v a 2s.c o m*/ mTextureView.invalidate(); mTextureView.setOpaque(false); logout = (Button) findViewById(R.id.logout); cast = (Button) findViewById(R.id.castAsmaster); doubtbutton = (Button) findViewById(R.id.doubt); viewbutton = (Button) findViewById(R.id.viewdoubt); pref = new PrefManager(getApplicationContext()); text.setText(ip); logout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pref.logout(); Intent i = new Intent(MainActivity_Reciever.this, LoginActivity.class); startActivity(i); finish(); } }); cast.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new allowcast().execute(); } }); viewbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //pref.logout(); // LOOK HERE ASH /*Intent i = new Intent(MainActivity_Reciever.this,DoubtActivity.class); startActivity(i);*/ new viewdoubttask().execute(); } }); doubtbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //pref.logout(); // LOOK HERE ASH /*Intent i = new Intent(MainActivity_Reciever.this,DoubtActivity.class); startActivity(i);*/ DoubtBox(); } }); mTask = new ReceiverAsyncTask(this); mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); Intent intent1 = new Intent(this, MyBroadcastReceiver.class); intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getBroadcast( getApplicationContext(), 234324243, intent1, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (10 * 1000), pendingIntent); }
From source file:com.orange.oidc.secproxy_service.Service.java
void resetCookies() { // init intent Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(Service.this, WebViewActivity.class); intent.putExtra("resetcookies", "true"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION); // launch webview startActivity(intent);//from w ww . j a v a2s. c o m }
From source file:com.zira.registration.BackgroundCheckActivity.java
private void forwardToNextScreen() { SingleTon.getInstance().setBg_address1(addressOneEditText.getText().toString()); // SingleTon.getInstance().setBg_address2(addressTwoEditText.getText().toString()); SingleTon.getInstance().setBg_zipcode(zipCodeEditText.getText().toString()); SingleTon.getInstance().setBg_drivingLicenseNumber(licenceNumberEditText.getText().toString()); // editor.putString("zipCode", zipCodeEditText.getText().toString()); // editor.putString("addressOne", addressOneEditText.getText().toString()); // editor.putString("licenceNumber", licenceNumberEditText.getText().toString()); // editor.commit(); //SingleTon.getInstance().setBg_city(""+gettingCityPosition); if (licenceExpirationDate.equals("")) { String getdate = mProfileInfoModel.getDrivinglicenseexpirationdate(); Date date = null;/* w ww .jav a 2 s . co m*/ try { date = getDateFormat.parse(getdate); String formattedDate = dateFormatToSend.format(date); SingleTon.getInstance().setBg_LicExoDate(formattedDate); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } /* String formattedDate = dateFormatToSend.format(date); SingleTon.getInstance().setBg_LicExoDate(formattedDate);*/ } else { SingleTon.getInstance().setBg_LicExoDate(licenceExpirationDate); } if (DOB.equals("")) { String getdatedob = mProfileInfoModel.getDateofbirth(); Date date = null; try { date = getDateFormat.parse(getdatedob); String formattedDate = dateFormatToSend.format(date); SingleTon.getInstance().setBgDOB(formattedDate); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { SingleTon.getInstance().setBgDOB(DOB); } SingleTon.getInstance().setBg_socialSecNumber(securityNumberEditText.getText().toString()); // editor.putString("securityNumber", securityNumberEditText.getText().toString()); // editor.commit(); //finish(); Intent intent = new Intent(BackgroundCheckActivity.this, DocumentUploadActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent); // startActivity(new Intent(BackgroundCheckActivity.this,DocumentUploadActivity.class)); }
From source file:de.madvertise.android.sdk.MadvertiseMraidView.java
public MadvertiseMraidView(Context context) { super(context); setVerticalScrollBarEnabled(false);//from www . j a va2s . com setHorizontalScrollBarEnabled(false); setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); setBackgroundColor(Color.TRANSPARENT); WebSettings settings = getSettings(); settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); settings.setJavaScriptEnabled(true); //settings.setPluginsEnabled(true); // Initialize the default expand properties. DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); mExpandProperties = new ExpandProperties(metrics.widthPixels, metrics.heightPixels); MadvertiseUtil.logMessage(null, Log.INFO, "Setting default expandProperties : " + mExpandProperties.toJson().toString()); // This bridge stays available until this view is destroyed, hence no // reloading when displaying new ads is necessary. addJavascriptInterface(mBridge, "mraid_bridge"); setWebViewClient(new WebViewClient() { private boolean mError = false; @Override public boolean shouldOverrideUrlLoading(WebView view, final String url) { post(new Runnable() { @Override public void run() { if (mListener != null) { mListener.onAdClicked(); } final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url), getContext().getApplicationContext(), MadvertiseActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); } }); return true; } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (!url.endsWith("mraid.js") && !mError) { MadvertiseUtil.logMessage(null, Log.DEBUG, "Setting mraid to default"); checkReady(); // Close button in default size for interstitial ads if (mPlacementType == MadvertiseUtil.PLACEMENT_TYPE_INTERSTITIAL) { mCloseButton = addCloseButtonToViewGroup(((ViewGroup) getParent())); mCloseButton.setImageResource(android.R.drawable.ic_menu_close_clear_cancel); } } } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); mError = true; } }); // Comment this in to enable video tag-capability. this.setWebChromeClient(new WebChromeClient() { @Override public void onShowCustomView(View view, CustomViewCallback callback) { MadvertiseUtil.logMessage(null, Log.INFO, "showing VideoView"); super.onShowCustomView(view, callback); if (view instanceof FrameLayout) { FrameLayout frame = (FrameLayout) view; if (frame.getFocusedChild() instanceof VideoView) { mVideo = (VideoView) ((FrameLayout) view).getFocusedChild(); frame.removeView(mVideo); ((ViewGroup) getParent()).addView(mVideo); // Will also be called onError mVideo.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer player) { player.stop(); } }); mVideo.setOnErrorListener(new OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { MadvertiseUtil.logMessage(null, Log.WARN, "Error while playing video"); if (mListener != null) { mListener.onError(new IOException("Error while playing video")); } // We return false in order to call // onCompletion() return false; } }); mVideo.start(); } } } @Override public void onHideCustomView() { if (mVideo != null) { ((ViewGroup) getParent()).removeView(mVideo); if (mVideo.isPlaying()) { mVideo.stopPlayback(); } } } }); }
From source file:com.mobicage.rogerthat.registration.ContentBrandingRegistrationActivity.java
private void tryConnect(final int attempt, final String statusMessage, final RegistrationInfo info) { T.UI();//from w ww .j a v a 2 s . c o m final Pausable pausable = this; if (attempt > XMPP_MAX_NUM_ATTEMPTS) { mProgressContainer.setVisibility(View.GONE); mButtonContainer.setVisibility(View.VISIBLE); new AlertDialog.Builder(ContentBrandingRegistrationActivity.this) .setMessage(getString(R.string.registration_error)).setCancelable(true) .setPositiveButton(R.string.try_again, null).create().show(); mWiz.reInit(); return; } mProgressContainer.setVisibility(View.VISIBLE); mButtonContainer.setVisibility(View.GONE); L.d("Registration attempt #" + attempt); final String xmppServiceName = info.mCredentials.getXmppServiceName(); final String xmppAccount = info.mCredentials.getXmppAccount(); final String xmppPassword = info.mCredentials.getPassword(); final ConfigurationProvider cp = mService.getConfigurationProvider(); Runnable runnable = new SafeRunnable() { @Override public void safeRun() { T.REGISTRATION(); try { if (CloudConstants.USE_XMPP_KICK_CHANNEL) { final ConnectionConfiguration xmppConfig = new XMPPConfigurationFactory(cp, mService.getNetworkConnectivityManager(), null) .getSafeXmppConnectionConfiguration(xmppServiceName); final XMPPConnection xmppCon = new XMPPConnection(xmppConfig); xmppCon.setLogger(new Logger() { @Override public void log(String message) { L.d(message); } }); xmppCon.connect(); xmppCon.login(xmppAccount, xmppPassword); final Thread t2 = new Thread(new SafeRunnable() { @Override protected void safeRun() throws Exception { L.d("REG Before disconnect (on separate thread) - xmpp-" + xmppCon.hashCode()); xmppCon.disconnect(); L.d("REG After disconnect (on separate thread) - xmpp-" + xmppCon.hashCode()); } }); t2.setDaemon(true); t2.start(); } postFinishRegistration(info.mCredentials.getUsername(), info.mCredentials.getPassword(), null, null); mUIHandler.post(new SafeRunnable(pausable) { @Override protected void safeRun() throws Exception { T.UI(); mWiz.setCredentials(info.mCredentials); if (CloudConstants.USE_GCM_KICK_CHANNEL && !"".equals(mGCMRegistrationId)) { GoogleServicesUtils.saveGCMRegistrationId(mService, mGCMRegistrationId); } mService.setCredentials(mWiz.getCredentials()); mService.setRegisteredInConfig(true); final Intent launchServiceIntent = new Intent(ContentBrandingRegistrationActivity.this, MainService.class); launchServiceIntent.putExtra(MainService.START_INTENT_JUST_REGISTERED, true); launchServiceIntent.putExtra(MainService.START_INTENT_MY_EMAIL, mWiz.getEmail()); ContentBrandingRegistrationActivity.this.startService(launchServiceIntent); Intent intent = new Intent(ContentBrandingRegistrationActivity.this, ContentBrandingMainActivity.class); intent.setAction(MainActivity.ACTION_REGISTERED); intent.setFlags(MainActivity.FLAG_CLEAR_STACK); startActivity(intent); ContentBrandingRegistrationActivity.this.finish(); } }); } catch (Exception e) { L.d("Exception while trying to end the registration process", e); mUIHandler.post(new SafeRunnable(pausable) { @Override protected void safeRun() throws Exception { T.UI(); tryConnect(attempt + 1, statusMessage, info); } }); } } }; if (attempt == 1) { mWorkerHandler.post(runnable); } else { mWorkerHandler.postDelayed(runnable, XMPP_CHECK_DELAY_MILLIS); } }
From source file:com.marianhello.cordova.bgloc.LocationUpdateService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(TAG, "Received start id " + startId + ": " + intent); if (intent != null) { try { params = new JSONObject(intent.getStringExtra("params")); headers = new JSONObject(intent.getStringExtra("headers")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace();/*ww w. j av a 2 s .co m*/ } url = intent.getStringExtra("url"); stationaryRadius = Float.parseFloat(intent.getStringExtra("stationaryRadius")); distanceFilter = Integer.parseInt(intent.getStringExtra("distanceFilter")); scaledDistanceFilter = distanceFilter; desiredAccuracy = Integer.parseInt(intent.getStringExtra("desiredAccuracy")); locationTimeout = Integer.parseInt(intent.getStringExtra("locationTimeout")); isDebugging = Boolean.parseBoolean(intent.getStringExtra("isDebugging")); notificationTitle = intent.getStringExtra("notificationTitle"); notificationText = intent.getStringExtra("notificationText"); // Build a Notification required for running service in foreground. Intent main = new Intent(this, BackgroundGpsPlugin.class); main.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); Notification.Builder builder = new Notification.Builder(this); builder.setContentTitle(notificationTitle); builder.setContentText(notificationText); builder.setSmallIcon(android.R.drawable.ic_menu_mylocation); builder.setContentIntent(pendingIntent); Notification notification; if (android.os.Build.VERSION.SDK_INT >= 16) { notification = buildForegroundNotification(builder); } else { notification = buildForegroundNotificationCompat(builder); } notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_FOREGROUND_SERVICE | Notification.FLAG_NO_CLEAR; startForeground(startId, notification); } Log.i(TAG, "- url: " + url); Log.i(TAG, "- params: " + params.toString()); Log.i(TAG, "- headers: " + headers.toString()); Log.i(TAG, "- stationaryRadius: " + stationaryRadius); Log.i(TAG, "- distanceFilter: " + distanceFilter); Log.i(TAG, "- desiredAccuracy: " + desiredAccuracy); Log.i(TAG, "- locationTimeout: " + locationTimeout); Log.i(TAG, "- isDebugging: " + isDebugging); Log.i(TAG, "- notificationTitle: " + notificationTitle); Log.i(TAG, "- notificationText: " + notificationText); this.setPace(false); //We want this service to continue running until it is explicitly stopped return START_REDELIVER_INTENT; }
From source file:gpsalarm.app.service.PostMonitor.java
private void showNotification(String str, String gid) { final NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification note = new Notification(R.drawable.status, "Locate@ Tweet", System.currentTimeMillis()); Intent i = new Intent(this, AlarmEdit3.class); i.putExtra("user", prefs.getString("user", null)); i.putExtra(ReminderHelper.GLOBAL_ID, gid); // i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| // Intent.FLAG_ACTIVITY_SINGLE_TOP); i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0); note.setLatestEventInfo(this, "Locate@ Tweet", str, pi); mgr.notify(NOTIFICATION_ID, note);/* w ww .ja va2 s. c om*/ }
From source file:abanoubm.dayra.main.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { if (Utility.getArabicLang(getApplicationContext()) == 1) { Utility.setArabicLang(getApplicationContext(), 2); Locale myLocale = new Locale("ar"); Resources res = getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale;/* www. j a v a 2 s . co m*/ res.updateConfiguration(conf, dm); finish(); startActivity(new Intent(getIntent())); } super.onCreate(savedInstanceState); setContentView(R.layout.act_main); ((TextView) findViewById(R.id.subhead1)).setText(R.string.app_name); ((TextView) findViewById(R.id.subhead2)).setText(BuildConfig.VERSION_NAME); findViewById(R.id.nav_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); ((TextView) findViewById(R.id.footer)).setText("dayra " + BuildConfig.VERSION_NAME + " @" + new SimpleDateFormat("yyyy", Locale.getDefault()).format(new Date()) + " Abanoub M."); if (!Utility.getDayraName(getApplicationContext()).equals("")) { startActivity(new Intent(getApplicationContext(), Home.class)); finish(); } ListView lv = (ListView) findViewById(R.id.home_list); mMenuItemAdapter = new MenuItemAdapter(getApplicationContext(), new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.sign_menu))), 1); lv.setAdapter(mMenuItemAdapter); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: sign(); break; case 1: register(); break; case 2: if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { importDB(); } else { ActivityCompat.requestPermissions(Main.this, new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE }, IMPORT_REQUEST); } break; case 3: startActivity(new Intent(Intent.ACTION_VIEW).setData( Uri.parse("https://drive.google.com/file/d/0B1rNCm5K9cvwVXJTTzNqSFdrVk0/view"))); break; case 4: startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse( "https://drive.google.com/open?id=1flSRdoiIT_hNd96Kxz3Ww3EhXDLZ45FhwFJ2hF9vl7g"))); break; case 5: { AlertDialog.Builder builder = new AlertDialog.Builder(Main.this); builder.setTitle(R.string.label_choose_language); builder.setItems(getResources().getStringArray(R.array.language_menu), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String temp; if (which == 1) { temp = "en"; Utility.setArabicLang(getApplicationContext(), 0); } else { temp = "ar"; Utility.setArabicLang(getApplicationContext(), 2); } Locale myLocale = new Locale(temp); Resources res = getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale; res.updateConfiguration(conf, dm); finish(); startActivity(new Intent(getIntent())); } }); builder.create().show(); } break; case 6: try { getPackageManager().getPackageInfo("com.facebook.katana", 0); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/453595434816965")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } catch (Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/dayraapp")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } break; case 7: try { getPackageManager().getPackageInfo("com.facebook.katana", 0); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/1363784786")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } catch (Exception e) { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/EngineeroBono")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } break; case 8: Uri uri = Uri.parse("market://details?id=" + getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); try { startActivity(goToMarket); } catch (Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName()))); } break; case 9: if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(Intent.ACTION_VIEW).addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); intent.setDataAndType(Uri.fromFile(new File(Utility.getDayraFolder())), "*/*"); startActivity( intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } else { ActivityCompat.requestPermissions(Main.this, new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE }, FOLDER_REQUEST); } break; case 10: LayoutInflater li = LayoutInflater.from(getApplicationContext()); final View aboutView = li.inflate(R.layout.dialogue_about, null, false); final AlertDialog ad = new AlertDialog.Builder(Main.this).setCancelable(true).create(); ad.setView(aboutView, 0, 0, 0, 0); ad.show(); ((TextView) aboutView.findViewById(R.id.about)) .setText(String.format(getResources().getString(R.string.copyright), Calendar.getInstance().get(Calendar.YEAR))); ((TextView) aboutView.findViewById(R.id.notice)).setText(GoogleApiAvailability.getInstance() .getOpenSourceSoftwareLicenseInfo(getApplicationContext())); aboutView.findViewById(R.id.btn).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ad.cancel(); } }); break; } } }); }