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:Main.java

public static void restartPC(final Activity activity) {
    if (activity == null)
        return;//from   w  ww.j a va2  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:Main.java

public static void restartApp(final Activity activity) {
    if (activity == null)
        return;/*from w  w w  . j  av a2 s. c  om*/
    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:com.becapps.easydownloader.utils.Utils.java

public static void reload(Activity activity) {
    Intent intent = activity.getIntent();
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    activity.finish();//from   w  ww.  j a  v a 2 s .  c o m
    activity.overridePendingTransition(0, 0);
    activity.startActivity(intent);
    activity.overridePendingTransition(0, 0);
}

From source file:com.android.contacts.common.activity.RequestPermissionsActivityBase.java

/**
 * If any permissions the Contacts app needs are missing, open an Activity
 * to prompt the user for these permissions. Moreover, finish the current activity.
 *
 * This is designed to be called inside {@link android.app.Activity#onCreate}
 */// w  ww  . ja  va 2 s. co m
protected static boolean startPermissionActivity(Activity activity, String[] requiredPermissions,
        Class<?> newActivityClass) {
    if (!hasPermissions(activity, requiredPermissions)) {
        final Intent intent = new Intent(activity, newActivityClass);
        activity.getIntent().putExtra(STARTED_PERMISSIONS_ACTIVITY, true);
        intent.putExtra(PREVIOUS_ACTIVITY_INTENT, activity.getIntent());
        activity.startActivity(intent);
        activity.finish();
        return true;
    }

    // Account type initialization must be delayed until the Contacts permission group
    // has been granted (since GET_ACCOUNTS) falls under that groups.  Previously it
    // was initialized in ContactApplication which would cause problems as
    // AccountManager.getAccounts would return an empty array. See b/22690336
    AccountTypeManager.getInstance(activity);

    return false;
}

From source file:Main.java

public static void restartTW(final Activity activity) {
    if (activity == null)
        return;/*from   w  w w. j  av a 2  s. com*/
    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:com.android.contacts.activities.RequestPermissionsActivityBase.java

protected static boolean startPermissionActivity(Activity activity, String[] requiredPermissions,
        boolean isCallerSelf, Class<?> newActivityClass) {
    if (!hasPermissions(activity, requiredPermissions)) {
        final Intent intent = new Intent(activity, newActivityClass);
        activity.getIntent().putExtra(EXTRA_STARTED_PERMISSIONS_ACTIVITY, true);
        intent.putExtra(PREVIOUS_ACTIVITY_INTENT, activity.getIntent());
        intent.putExtra(EXTRA_IS_CALLER_SELF, isCallerSelf);
        activity.startActivity(intent);/*w  w w  .j a  va 2  s.  c om*/
        activity.finish();
        return true;
    }

    // Account type initialization must be delayed until the Contacts permission group
    // has been granted (since GET_ACCOUNTS) falls under that groups.  Previously it
    // was initialized in ContactApplication which would cause problems as
    // AccountManager.getAccounts would return an empty array. See b/22690336
    AccountTypeManager.getInstance(activity);

    return false;
}

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

public static void openRemote(Activity activity, RemoteProfile remoteProfile, boolean isMain) {
    AppPreferences appPreferences = VuzeRemoteApp.getAppPreferences();

    if (appPreferences.getRemote(remoteProfile.getID()) == null) {
        appPreferences.addRemoteProfile(remoteProfile);
    }//from  w ww. j a v a  2  s  .c o m

    Intent myIntent = new Intent(activity.getIntent());
    myIntent.setAction(Intent.ACTION_VIEW);
    myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    if (isMain) {
        myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        // Scenario:
        // User has multiple remote hosts.
        // User clicks on torrent link in browser.
        // User is displayed remote selector activity (IntenntHandler) and picks
        // Remote activity is opened, torrent is added
        // We want the back button to go back to the browser.  Going back to
        // the remote selector would be confusing (especially if they then chose
        // another remote!)
        myIntent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
    }
    myIntent.setClass(activity, TorrentViewActivity.class);

    myIntent.putExtra(SessionInfoManager.BUNDLE_KEY, remoteProfile.getID());

    activity.startActivity(myIntent);

}

From source file:edu.stanford.junction.android.AndroidJunctionMaker.java

public static boolean isJoinable(Activity a) {
    return (isJoinable(a.getIntent()));
}

From source file:com.mediatek.contacts.activities.ActivitiesUtils.java

public static void customAccountsList(List<AccountWithDataSet> accountList, Activity activity) {
    if (accountList != null) {
        int type = activity.getIntent().getIntExtra(ContactsSettingsUtils.ACCOUNT_TYPE,
                ContactsSettingsUtils.ALL_TYPE_ACCOUNT);
        switch (type) {
        case ContactsSettingsUtils.PHONE_TYPE_ACCOUNT:
            Iterator<AccountWithDataSet> iterator = accountList.iterator();
            while (iterator.hasNext()) {
                AccountWithDataSet data = iterator.next();
                // Only sim account is AccountWithDataSetEx, so remove any
                // type is AccountWithDataSetEx
                if (isSimType(data.type)) {
                    iterator.remove();/* ww w  . j a va2 s.  c om*/
                }
            }
            break;
        default:
            Log.i(TAG, "[customAccountsList]default all type account");
            break;
        }
    }
}

From source file:com.facebook.AppLinkData.java

/**
 * Parses out any app link data from the Intent of the Activity passed in.
 * @param activity Activity that was started because of an app link
 * @return AppLinkData if found. null if not.
 *//*  w w w.j a v a  2  s . co  m*/
public static AppLinkData createFromActivity(Activity activity) {
    Validate.notNull(activity, "activity");
    Intent intent = activity.getIntent();
    if (intent == null) {
        return null;
    }

    AppLinkData appLinkData = createFromAlApplinkData(intent);
    if (appLinkData == null) {
        String appLinkArgsJsonString = intent.getStringExtra(BUNDLE_APPLINK_ARGS_KEY);
        appLinkData = createFromJson(appLinkArgsJsonString);
    }
    if (appLinkData == null) {
        // Try regular app linking
        appLinkData = createFromUri(intent.getData());
    }

    return appLinkData;
}