Example usage for android.app Activity getIntent

List of usage examples for android.app Activity getIntent

Introduction

In this page you can find the example usage for android.app Activity getIntent.

Prototype

public Intent getIntent() 

Source Link

Document

Return the intent that started this activity.

Usage

From source file:com.vuze.android.remote.VuzeEasyTrackerOld.java

/**
 * @param arg0/*  ww w.j  a  va 2 s. c om*/
 * @see com.google.analytics.tracking.android.EasyTracker#activityStart(android.app.Activity)
 */
public void activityStart(Activity activity) {

    easyTracker.set(Fields.SCREEN_NAME, activity.getClass().getSimpleName());
    MapBuilder mapBuilder = MapBuilder.createAppView().set(Fields.SCREEN_NAME,
            activity.getClass().getSimpleName());
    Intent intent = activity.getIntent();
    if (intent != null) {
        Uri data = intent.getData();
        if (data != null) {
            mapBuilder.setAll(getReferrerMapFromUri(data));
        }
    }
    easyTracker.send(mapBuilder.build());
}

From source file:com.afwsamples.testdpc.SetupManagementFragment.java

private void maybeSpecifySyncAuthExtras(Intent intent, PersistableBundle adminExtras) {
    Activity activity = getActivity();
    Intent launchIntent = activity.getIntent();

    if (!LaunchIntentUtil.isSynchronousAuthLaunch(launchIntent)) {
        // Don't do anything if this isn't a sync-auth flow.
        return;//w w  w .ja v a2 s  .c om
    }

    Account accountToMigrate = LaunchIntentUtil.getAddedAccount(launchIntent);
    if (accountToMigrate != null) {
        // EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE only supported in API 22+.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
            // Configure the account to migrate into the managed profile if setup
            // completes.
            intent.putExtra(EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE, accountToMigrate);
        } else {
            Toast.makeText(activity, R.string.migration_not_supported, Toast.LENGTH_SHORT).show();
        }
    }

    // Perculate launch intent extras through to DeviceAdminReceiver so they can be used there.
    LaunchIntentUtil.prepareDeviceAdminExtras(launchIntent, adminExtras);
}

From source file:io.branch.sdk.TitaniumDeferredDeepLinkingSDKModule.java

@Kroll.method
public void initSession() {
    Log.d(LCAT, "start init");
    final Activity activity = this.getActivity();
    final Branch instance = Branch.getAutoInstance(TiApplication.getInstance());

    instance.initSession(new SessionListener(), activity.getIntent().getData(), activity);
}

From source file:com.amaze.carbonfilemanager.activities.PreferencesActivity.java

public void restartPC(final Activity activity) {
    if (activity == null)
        return;//from  w ww. j  a va 2  s . c  o m
    final int enter_anim = android.R.anim.fade_in;
    final int exit_anim = android.R.anim.fade_out;
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.finish();
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.startActivity(activity.getIntent());
}

From source file:io.branch.sdk.TitaniumDeferredDeepLinkingSDKModule.java

@Kroll.method
public void initSessionWithData(String data) {
    Log.d(LCAT, "start init");
    final Activity activity = this.getActivity();
    final Branch instance = Branch.getAutoInstance(TiApplication.getInstance());

    if (data == null) {
        instance.initSession(new SessionListener(), activity.getIntent().getData(), activity);
    } else {/*  w ww .  ja  va2  s  .c  o  m*/
        Uri uri = Uri.parse(data);
        instance.initSession(new SessionListener(), uri, activity);
    }
}

From source file:me.acristoffers.tracker.fragments.PackageEditFragment.java

private void setupUI() {
    final Activity activity = getActivity();
    view = getView();//w  ww. jav a  2s  .  c  om

    if (activity == null || view == null) {
        return;
    }

    String code = null;

    final Bundle arguments = getArguments();
    if (arguments != null) {
        code = arguments.getString(PackageDetailsActivity.PACKAGE_CODE);
    }

    if (code == null || code.isEmpty()) {
        final Intent intent = activity.getIntent();
        if (intent != null) {
            code = intent.getStringExtra(PackageDetailsActivity.PACKAGE_CODE);
        }
    }

    if (code == null || code.isEmpty()) {
        return;
    }

    pkg = new Package(code, activity, null);

    final EditText editText = (EditText) view.findViewById(R.id.name);
    if (editText != null) {
        editText.setText(pkg.getName());
    }

    final SwitchCompat switchCompat = (SwitchCompat) view.findViewById(R.id.active);
    if (switchCompat != null) {
        switchCompat.setChecked(pkg.isActive());
    }
}

From source file:com.google.cloud.solutions.cloudadventure.PreGameFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    // Set the callback activity to use
    try {//from www. ja  va 2 s.  c o m
        callback = (OnPreGameClickListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must implement OnPreGameClickListener");
    }

    // Handle entrance logic
    if (Constants.GAME_ENTRANCE_ACTION_CREATOR
            .equals(activity.getIntent().getStringExtra(Constants.GAME_ENTRANCE_ACTION_INTENT_EXTRA_KEY))) {
        mIsCreator = true;
    } else {
        mIsCreator = false;
    }
}

From source file:com.zzolta.android.gfrecipes.fragments.RecipeDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = parallaxScrollAppCompat.createView(inflater);
    final RecipeDetailHelper recipeDetailHelper = RecipeDetailHelper.getInstance();
    final Activity activity = getActivity();
    recipeDetailHelper.setActivity(activity);
    recipeDetailHelper.setView(view);//from w  ww  .java  2  s.  co m
    String recipeID = null;
    if (activity instanceof SearchResultsActivity) {
        if (((SearchResultsActivity) activity).isTwoPane()) {
            recipeID = getArguments().getString(ApplicationConstants.RECIPE_ID);
        } else {
            recipeID = activity.getIntent().getStringExtra(ApplicationConstants.RECIPE_ID);
        }
    } else if (activity instanceof RecipeDetailActivity) {
        recipeID = activity.getIntent().getStringExtra(ApplicationConstants.RECIPE_ID);
    } else if (activity instanceof MyRecipesActivity) {
        if (((MyRecipesActivity) activity).isTwoPane()) {
            recipeID = getArguments().getString(ApplicationConstants.RECIPE_ID);
        } else {
            recipeID = activity.getIntent().getStringExtra(ApplicationConstants.RECIPE_ID);
        }
    } else {
        //it is a MainActivity
    }

    if (recipeID != null) {
        //recipe detail
        final Recipe recipe = getRecipeFromDatabase(recipeID);
        if (recipe != null) {
            recipeDetailHelper.loadData(recipe);
        } else {
            getRecipeUsingREST(recipeID);
        }
    } else {
        //recipe of the day
        final String recipeOfTheDayId = this.getArguments()
                .getString(ApplicationConstants.RECIPE_OF_THE_DAY_ID);
        if (recipeOfTheDayId == null) {
            loadRecipeOfTheDay();
        } else {
            recipeDetailHelper.loadData(getRecipeFromDatabase(recipeOfTheDayId));
        }
    }
    setHasOptionsMenu(true);
    return view;
}

From source file:com.vuze.android.remote.AppPreferences.java

public void showRateDialog(final Activity mContext) {

    if (!shouldShowRatingReminder()) {
        return;/* ww  w. j a va  2s .c  om*/
    }

    // skip showing if they are adding a torrent (or anything else)
    Intent intent = mContext.getIntent();
    if (intent != null) {
        Uri data = intent.getData();
        if (data != null) {
            return;
        }
    }

    // even if something goes wrong, we want to set that we asked, so
    // it doesn't continue to pop up
    setAskedRating();

    Dialog dialog = new Dialog(mContext);

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setMessage(R.string.ask_rating_message).setCancelable(false)
            .setPositiveButton(R.string.rate_now, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    final String appPackageName = mContext.getPackageName();
                    try {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("market://details?id=" + appPackageName)));
                    } catch (android.content.ActivityNotFoundException anfe) {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
                    }
                    VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskStoreClick",
                            null);
                }
            }).setNeutralButton(R.string.later, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).setNegativeButton(R.string.no_thanks, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    setNeverAskRatingAgain();
                }
            });
    dialog = builder.create();

    VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskShown", null);
    dialog.show();
}

From source file:me.acristoffers.tracker.fragments.PackageDetailsFragment.java

private void setupUI() {
    final Activity activity = getActivity();
    final View view = getView();

    if (activity == null || view == null) {
        return;//w  ww.jav  a 2 s.  com
    }

    String code = null;

    final Bundle arguments = getArguments();
    if (arguments != null) {
        code = arguments.getString(PackageDetailsActivity.PACKAGE_CODE);
    }

    if (code == null || code.isEmpty()) {
        final Intent intent = activity.getIntent();
        if (intent != null) {
            code = intent.getStringExtra(PackageDetailsActivity.PACKAGE_CODE);
        }
    }

    if (code == null || code.isEmpty()) {
        return;
    }

    final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.steps);

    final RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(activity);
    recyclerView.setLayoutManager(layoutManager);

    pkg = new Package(code, getActivity(), null);

    final StepListAdapter stepListAdapter = new StepListAdapter(pkg, activity);
    recyclerView.setAdapter(stepListAdapter);

    TextView textView = (TextView) view.findViewById(R.id.name);
    textView.setText(pkg.getName());

    textView = (TextView) view.findViewById(R.id.code);
    textView.setText(pkg.getCod());
    textView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            final ClipboardManager clipboardManager = (ClipboardManager) activity
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            if (clipboardManager != null) {
                final String code = pkg.getCod();

                final ClipData clipData = ClipData.newPlainText(code, code);
                clipboardManager.setPrimaryClip(clipData);

                final Toast toast = Toast.makeText(activity, R.string.code_copied, Toast.LENGTH_SHORT);
                toast.show();

                return true;
            }

            return false;
        }
    });

    if (!pkg.getSteps().isEmpty()) {
        textView = (TextView) view.findViewById(R.id.emptyStepView);
        textView.setVisibility(View.INVISIBLE);
    }

    final NotificationManager nm = (NotificationManager) activity
            .getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(pkg.getId());
}