Example usage for android.app Activity startActivity

List of usage examples for android.app Activity startActivity

Introduction

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

Prototype

@Override
public void startActivity(Intent intent) 

Source Link

Document

Same as #startActivity(Intent,Bundle) with no options specified.

Usage

From source file:com.sean.nanastudio.taoyuanstreetparking.MainActivity.java

public static void startInstalledAppDetailsActivity(final Activity context) {
    if (context == null) {
        return;//from w  w  w.j  a v a 2  s .  c om
    }
    final Intent i = new Intent();
    i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    i.addCategory(Intent.CATEGORY_DEFAULT);
    i.setData(Uri.parse("package:" + context.getPackageName()));
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    context.startActivity(i);
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * Launch the {@link GroupContactsActivity}.
 *
 * @param activity The context used to start this intent
 * @param group    group data/*from   w w w  .j a  v a  2 s  .c  o m*/
 */
public static void launchEditGroupContactsActivity(Activity activity, Group group) {
    Intent intent = new Intent(Intents.ACTION_VIEW_GROUP_USERS);
    intent.putExtra(ARG_SELECTED_GROUP, group);
    activity.startActivity(intent);
    activity.overridePendingTransition(R.anim.slide_in_bottom, R.anim.fade_out);
}

From source file:com.arantius.tivocommander.Utils.java

public final static boolean onOptionsItemSelected(MenuItem item, Activity srcActivity, boolean homeIsBack) {
    if (android.R.id.home == item.getItemId() && homeIsBack) {
        srcActivity.finish();//  w  ww . ja  va2  s.  co m
        return true;
    }

    Class<? extends Activity> targetActivity = Utils.activityForMenuId(item.getItemId());
    if (targetActivity == null) {
        Utils.logError("Unknown menu item ID: " + Integer.toString(item.getItemId()));
        return false;
    }
    Intent intent = new Intent(srcActivity, targetActivity);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    srcActivity.startActivity(intent);
    return true;
}

From source file:com.poguico.palmabici.widgets.SidebarMenu.java

public static void setDrawer(final Activity activity) {
    context = activity.getApplicationContext();
    elements = initElements();/*w w  w .  ja va2s  .c o  m*/

    mDrawerLayout = (DrawerLayout) activity.findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) activity.findViewById(R.id.left_drawer);

    mDrawerList.setAdapter(new SidebarElementAdapter(context, elements));
    mDrawerList.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
            if (position == 0) {
                Intent preferencesActivity = new Intent(activity, PreferencesActivity.class);
                activity.startActivity(preferencesActivity);
            } else if (position == 1) {
                Intent issueIntent = new Intent(Intent.ACTION_VIEW);
                issueIntent.setData(Uri.parse(GPLAY_URL));
                activity.startActivity(issueIntent);
            } else if (position == 2) {
                Intent shareActivity = new Intent(activity, ShareActivity.class);
                activity.startActivity(shareActivity);
            } else if (position == 3) {
                Intent issueIntent = new Intent(Intent.ACTION_VIEW);
                issueIntent.setData(Uri.parse(CONTACT_URL));
                activity.startActivity(issueIntent);
            } else if (position == 4) {
                new CreditsDialog(activity).show();
            }

            new Handler().postDelayed(closeDrawerRunnable(), 200);
        }
    });

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    mDrawerToggle = new ActionBarDrawerToggle(activity, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };

    mDrawerLayout.post(new Runnable() {
        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });

    mDrawerLayout.setDrawerListener(mDrawerToggle);

}

From source file:com.android.settings.util.Helpers2.java

/**
 * Restart the activity smoothly/*from w  ww . ja  v a 2s  . co m*/
 *
 * @param activity
 */
public static void restartPC(final Activity activity) {
    if (activity == null)
        return;
    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.mediatek.contacts.activities.ActivitiesUtils.java

public static boolean deleteContact(Activity activity) {
    Log.i(TAG, "[deleteContact]...");
    if (MultiChoiceService.isProcessing(MultiChoiceService.TYPE_DELETE)) {
        Toast.makeText(activity, R.string.contact_delete_all_tips, Toast.LENGTH_SHORT).show();
        return true;
    } else if (VCardService.isProcessing(VCardService.TYPE_IMPORT)
            || VCardService.isProcessing(VCardService.TYPE_EXPORT)) {
        Toast.makeText(activity, R.string.contact_import_export_tips, Toast.LENGTH_SHORT).show();
        return true;
    }/*  w ww  . j  a v a 2s  .  com*/
    activity.startActivity(new Intent()
            .setClassName(activity.getApplicationContext(),
                    "com.mediatek.contacts.list.ContactListMultiChoiceActivity")
            .setAction(com.mediatek.contacts.util.ContactsIntent.LIST.ACTION_DELETE_MULTI_CONTACTS));
    return true;
}

From source file:com.github.socialc0de.gsw.android.MainActivity.java

/**
 * Called to sign out the user, so user can later on select a different account.
 *
 * @param activity activity that initiated the sign out.
 *//*from  w w w  .  j  a va2  s  .  com*/
static void onSignOut(Activity activity) {
    SharedPreferences settings = activity.getSharedPreferences("reguees", 0);

    SharedPreferences.Editor editor = settings.edit();
    editor.putString(ACCOUNT_NAME_SETTING_NAME, "");

    editor.commit();
    credential.setSelectedAccountName("");

    Intent intent = new Intent(activity, MainActivity.class);
    activity.startActivity(intent);
}

From source file:com.oo58.game.texaspoker.AppActivity.java

public static void callCustomService(final String number) {
    final Activity ctx = mAct;
    ctx.runOnUiThread(new Runnable() {
        @Override/* w ww  . j  a v a  2 s.  co  m*/
        public void run() {
            // TODO Auto-generated method stub
            try {
                Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number));
                ctx.startActivity(intent);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });
}

From source file:com.google.samples.apps.iosched.util.PermissionsUtils.java

private static Snackbar displayPermissionDeniedAppInfoResolutionSnackbar(@NonNull final Activity activity,
        final int messageResId, final boolean isPersistent) {
    View view = UIUtils.getRootView(activity);
    final int length = isPersistent ? Snackbar.LENGTH_INDEFINITE : Snackbar.LENGTH_LONG;

    Snackbar snackbar = Snackbar.make(view, messageResId, length).setAction(R.string.ok,
            new View.OnClickListener() {
                @Override/*from  ww  w .java 2  s.  c o  m*/
                public void onClick(final View v) {
                    LOGI(TAG, "Invoking App Info screen");
                    final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null);
                    intent.setData(uri);
                    activity.startActivity(intent);
                }
            });
    snackbar.show();
    return snackbar;
}

From source file:com.auth0.lock.passwordless.LockPasswordlessActivity.java

public static void showFrom(Activity activity, int passwordlessType) {
    Intent intent = new Intent(activity, LockPasswordlessActivity.class);
    if (passwordlessType != MODE_EMAIL_CODE && passwordlessType != MODE_EMAIL_MAGIC_LINK
            && passwordlessType != MODE_SMS_CODE && passwordlessType != MODE_SMS_MAGIC_LINK) {
        Log.e(TAG,//from  w  w w.  j  a  va  2 s  .c om
                "Invalid passwordless type, it must be one of {MODE_EMAIL_CODE, MODE_EMAIL_MAGIC_LINK, MODE_SMS_CODE, MODE_SMS_MAGIC_LINK}");
        return;
    }
    intent.putExtra(PASSWORDLESS_TYPE_PARAMETER, passwordlessType);
    activity.startActivity(intent);
}