List of usage examples for android.app Activity getIntent
public Intent getIntent()
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void addGeofenceListener(CallbackContext callbackContext) { geofenceCallbacks.add(callbackContext); Activity activity = this.cordova.getActivity(); Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload") && launchIntent.hasExtra("geofencingEvent")) { try {//from www .j a v a2s . c o m JSONObject geofencingEvent = new JSONObject(launchIntent.getStringExtra("geofencingEvent")); handleGeofencingEvent(geofencingEvent); } catch (JSONException e) { Log.w(TAG, e); } } }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void addMotionChangeListener(CallbackContext callbackContext) { motionChangeCallbacks.add(callbackContext); Activity activity = this.cordova.getActivity(); Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload")) { if (launchIntent.getStringExtra("name") .equalsIgnoreCase(BackgroundGeolocationService.ACTION_ON_MOTION_CHANGE)) { Bundle event = launchIntent.getExtras(); this.onEventMainThread(event); }/*from ww w. j a va2s .c o m*/ launchIntent.removeExtra("forceReload"); launchIntent.removeExtra("location"); } }
From source file:com.facebook.AppEventsLogger.java
/** * Source Application setters and getters *///from ww w. j a va 2 s. c o m private static void setSourceApplication(Activity activity) { ComponentName callingApplication = activity.getCallingActivity(); if (callingApplication != null) { String callingApplicationPackage = callingApplication.getPackageName(); if (callingApplicationPackage.equals(activity.getPackageName())) { // open by own app. resetSourceApplication(); return; } sourceApplication = callingApplicationPackage; } // Tap icon to open an app will still get the old intent if the activity was opened by an intent before. // Introduce an extra field in the intent to force clear the sourceApplication. Intent openIntent = activity.getIntent(); if (openIntent == null || openIntent.getBooleanExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, false)) { resetSourceApplication(); return; } Bundle applinkData = AppLinks.getAppLinkData(openIntent); if (applinkData == null) { resetSourceApplication(); return; } isOpenedByApplink = true; Bundle applinkReferrerData = applinkData.getBundle("referer_app_link"); if (applinkReferrerData == null) { sourceApplication = null; return; } String applinkReferrerPackage = applinkReferrerData.getString("package"); sourceApplication = applinkReferrerPackage; // Mark this intent has been used to avoid use this intent again and again. openIntent.putExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, true); return; }
From source file:com.facebook.appevents.AppEventsLogger.java
/** * Source Application setters and getters *//* w w w .ja v a2 s. c o m*/ private static void setSourceApplication(Activity activity) { ComponentName callingApplication = activity.getCallingActivity(); if (callingApplication != null) { String callingApplicationPackage = callingApplication.getPackageName(); if (callingApplicationPackage.equals(activity.getPackageName())) { // open by own app. resetSourceApplication(); return; } sourceApplication = callingApplicationPackage; } // Tap icon to open an app will still get the old intent if the activity was opened by an // intent before. Introduce an extra field in the intent to force clear the // sourceApplication. Intent openIntent = activity.getIntent(); if (openIntent == null || openIntent.getBooleanExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, false)) { resetSourceApplication(); return; } Bundle applinkData = AppLinks.getAppLinkData(openIntent); if (applinkData == null) { resetSourceApplication(); return; } isOpenedByApplink = true; Bundle applinkReferrerData = applinkData.getBundle("referer_app_link"); if (applinkReferrerData == null) { sourceApplication = null; return; } String applinkReferrerPackage = applinkReferrerData.getString("package"); sourceApplication = applinkReferrerPackage; // Mark this intent has been used to avoid use this intent again and again. openIntent.putExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, true); return; }
From source file:paulscode.android.mupen64plusae.persistent.UserPrefs.java
public void changeLocale(final Activity activity) { // Get the index of the current locale final int currentIndex = ArrayUtils.indexOf(mLocaleCodes, mLocaleCode); // Populate and show the language menu Builder builder = new Builder(activity); builder.setTitle(R.string.menuItem_localeOverride); builder.setSingleChoiceItems(mLocaleNames, currentIndex, new DialogInterface.OnClickListener() { @Override//from w w w .ja v a 2 s. c om public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (which >= 0 && which != currentIndex) { mPreferences.edit().putString(KEY_LOCALE_OVERRIDE, mLocaleCodes[which]).commit(); activity.finish(); activity.startActivity(activity.getIntent()); } } }); builder.create().show(); }
From source file:com.android.camera.v2.uimanager.ThumbnailManager.java
/** * Create a thumbnail manager controller. * @param appcontroller controller used to get service for storage. * @param activity the current activity. * @param parent view group.// w w w . j a v a 2 s .c o m * @param secureCamera whether the current camera is secure camera or not. */ public ThumbnailManager(AppController appcontroller, Activity activity, ViewGroup parent, boolean secureCamera) { super(activity, parent); mIsSecureCamera = secureCamera; setFilterEnable(false); mStorageService = appcontroller.getAppControllerAdapter().getServices().getStorageService(); mActivity = activity; mContentResolver = activity.getContentResolver(); mMaiHandler = new Handler(activity.getMainLooper()); HandlerThread t = new HandlerThread("thumbnail-creation-thread"); t.start(); mHandler = new ThumbnailCreatorHandler(t.getLooper()); mThumbnailAnimation = new ThumbnailAnimation(); LocalBroadcastManager manager = LocalBroadcastManager.getInstance(mActivity); manager.registerReceiver(mUpdatePictureReceiver, mUpdatePictureFilter); mActivity.registerReceiver(mIpoShutdownReceiver, mIpoShutdownFilter); mIntent = activity.getIntent(); String action = null; if (mIntent != null) { action = mIntent.getAction(); } if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) || MediaStore.ACTION_VIDEO_CAPTURE.equals(action) || CameraUtil.ACTION_STEREO3D.equals(action)) { mShownByIntent = false; } }
From source file:com.android.tv.settings.dialog.old.BaseDialogFragment.java
public void performEntryTransition(final Activity activity, final ViewGroup contentView, int iconResourceId, Uri iconResourceUri, final ImageView icon, final TextView title, final TextView description, final TextView breadcrumb) { // Pull out the root layout of the dialog and set the background drawable, to be // faded in during the transition. final ViewGroup twoPane = (ViewGroup) contentView.getChildAt(0); twoPane.setVisibility(View.INVISIBLE); // If the appropriate data is embedded in the intent and there is an icon specified // in the content fragment, we animate the icon from its initial position to the final // position. Otherwise, we perform a simpler transition in which the ActionFragment // slides in and the ContentFragment text fields slide in. mIntroAnimationInProgress = true;//from w w w. jav a 2 s . com List<TransitionImage> images = TransitionImage.readMultipleFromIntent(activity, activity.getIntent()); TransitionImageAnimation ltransitionAnimation = null; final Uri iconUri; final int color; if (images != null && images.size() > 0) { if (iconResourceId != 0) { iconUri = Uri.parse(UriUtils.getAndroidResourceUri(activity, iconResourceId)); } else if (iconResourceUri != null) { iconUri = iconResourceUri; } else { iconUri = null; } TransitionImage src = images.get(0); color = src.getBackground(); if (iconUri != null) { ltransitionAnimation = new TransitionImageAnimation(contentView); ltransitionAnimation.addTransitionSource(src); ltransitionAnimation.transitionDurationMs(ANIMATE_IN_DURATION).transitionStartDelayMs(0) .interpolator(new DecelerateInterpolator(1f)); } } else { iconUri = null; color = 0; } final TransitionImageAnimation transitionAnimation = ltransitionAnimation; // Fade out the old activity, and hard cut the new activity. activity.overridePendingTransition(R.anim.hard_cut_in, R.anim.fade_out); int bgColor = mFragment.getResources().getColor(R.color.dialog_activity_background); mBgDrawable.setColor(bgColor); mBgDrawable.setAlpha(0); twoPane.setBackground(mBgDrawable); // If we're animating the icon, we create a new ImageView in which to place the embedded // bitmap. We place it in the root layout to match its location in the previous activity. mShadowLayer = (FrameLayoutWithShadows) twoPane.findViewById(R.id.shadow_layout); if (transitionAnimation != null) { transitionAnimation.listener(new TransitionImageAnimation.Listener() { @Override public void onRemovedView(TransitionImage src, TransitionImage dst) { if (icon != null) { //want to make sure that users still see at least the source image // if the dst image is too large to finish downloading before the // animation is done. Check if the icon is not visible. This mean // BaseContentFragement have not finish downloading the image yet. if (icon.getVisibility() != View.VISIBLE) { icon.setImageDrawable(src.getBitmap()); int intrinsicWidth = icon.getDrawable().getIntrinsicWidth(); LayoutParams lp = icon.getLayoutParams(); lp.height = lp.width * icon.getDrawable().getIntrinsicHeight() / intrinsicWidth; icon.setVisibility(View.VISIBLE); } icon.setAlpha(1f); } if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(1f); } onIntroAnimationFinished(); } }); icon.setAlpha(0f); if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(0f); } } // We need to defer the remainder of the animation preparation until the first // layout has occurred, as we don't yet know the final location of the icon. twoPane.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { twoPane.getViewTreeObserver().removeOnGlobalLayoutListener(this); // if we buildLayer() at this time, the texture is actually not created // delay a little so we can make sure all hardware layer is created before // animation, in that way we can avoid the jittering of start animation twoPane.postOnAnimationDelayed(mEntryAnimationRunnable, ANIMATE_DELAY); } final Runnable mEntryAnimationRunnable = new Runnable() { @Override public void run() { if (!mFragment.isAdded()) { // We have been detached before this could run, so just bail return; } twoPane.setVisibility(View.VISIBLE); final int secondaryDelay = SLIDE_IN_DISTANCE; // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(mBgDrawable, "alpha", 255); oa.setDuration(ANIMATE_IN_DURATION); oa.setStartDelay(secondaryDelay); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); View actionFragmentView = activity.findViewById(mActionAreaId); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE; int endDist = isRtl ? -actionFragmentView.getMeasuredWidth() : actionFragmentView.getMeasuredWidth(); // Fade in and slide in the ContentFragment TextViews from the start. prepareAndAnimateView(title, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); prepareAndAnimateView(breadcrumb, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); prepareAndAnimateView(description, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); // Fade in and slide in the ActionFragment from the end. prepareAndAnimateView(actionFragmentView, 0, endDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); if (icon != null && transitionAnimation != null) { // now we get the icon view in place, update the transition target TransitionImage target = new TransitionImage(); target.setUri(iconUri); target.createFromImageView(icon); if (icon.getBackground() instanceof ColorDrawable) { ColorDrawable d = (ColorDrawable) icon.getBackground(); target.setBackground(d.getColor()); } transitionAnimation.addTransitionTarget(target); transitionAnimation.startTransition(); } else if (icon != null) { prepareAndAnimateView(icon, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), true /* is the icon */); if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(0f); } } } }; }); }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void setEnabled(boolean value) { // Don't set a state that we're already in. Log.i(TAG, "- Enable: " + isEnabled + " " + value); Activity activity = cordova.getActivity(); boolean wasEnabled = isEnabled; isEnabled = value;/*from w w w. j a v a 2 s .c o m*/ isMoving = null; Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload")) { if (launchIntent.hasExtra("location")) { try { JSONObject location = new JSONObject(launchIntent.getStringExtra("location")); onLocationChange(location); } catch (JSONException e) { Log.w(TAG, e); } } } SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("enabled", isEnabled); editor.apply(); EventBus eventBus = EventBus.getDefault(); if (isEnabled) { synchronized (eventBus) { if (!eventBus.isRegistered(this)) { eventBus.register(this); } } if (!BackgroundGeolocationService.isInstanceCreated()) { activity.startService(backgroundServiceIntent); } else { final Bundle event = new Bundle(); if (!wasEnabled) { event.putString("name", BackgroundGeolocationService.ACTION_START); } else { event.putString("name", BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION); } event.putBoolean("request", true); postEvent(event); onStarted(event); } } else { Bundle event = new Bundle(); event.putString("name", BackgroundGeolocationService.ACTION_STOP); event.putBoolean("request", true); postEvent(event); synchronized (eventBus) { if (eventBus.isRegistered(this)) { eventBus.unregister(this); } } //activity.stopService(backgroundServiceIntent); backgroundServiceIntent = null; } }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
@Override protected void pluginInitialize() { gWebView = this.webView; Activity activity = this.cordova.getActivity(); settings = activity.getSharedPreferences("TSLocationManager", 0); Settings.init(settings);// w w w .j a v a 2s . co m toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload")) { // When Activity is launched due to forceReload, minimize the app. activity.moveTaskToBack(true); } }
From source file:br.com.mybaby.contatos.ContactsListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*from www . ja v a 2 s.com*/ // Assign callback listener which the holding activity must implement. This is used // so that when a contact item is interacted with (selected by the user) the holding // activity will be notified and can take further action such as populating the contact // detail pane (if in multi-pane layout) or starting a new activity with the contact // details (single pane layout). mOnContactSelectedListener = (OnContactsInteractionListener) activity; activity.getIntent().putExtra(extraSMSTel, extraSMSTel); } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnContactsInteractionListener"); } }