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.bluros.music.utils.NavigationUtils.java

public static void navigateToNowplaying(Activity context, boolean withAnimations) {

    final Intent intent = new Intent(context, NowPlayingActivity.class);
    if (!PreferencesUtility.getInstance(context).getSystemAnimations()) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    }//from   w w w . jav  a 2s  .  co  m
    context.startActivity(intent);
}

From source file:Main.java

public static void bindOnClick(final Activity context, int viewId, final Class<?> clazz, final int flags) {
    View view = (View) context.findViewById(viewId);

    view.setOnClickListener(new View.OnClickListener() {

        @Override// ww  w  .  ja v  a2  s .  c o  m
        public void onClick(View v) {
            Intent intent = new Intent(context, clazz);
            if (flags > 0) {
                intent.setFlags(flags);
            }
            context.startActivity(intent);

        }
    });

}

From source file:cgeo.geocaching.AboutActivity.java

public static void showChangeLog(final Activity fromActivity) {
    final Intent intent = new Intent(fromActivity, AboutActivity.class);
    intent.putExtra(EXTRA_ABOUT_STARTPAGE, Page.CHANGELOG.ordinal());
    fromActivity.startActivity(intent);
}

From source file:com.farproc.wifi.connecter.TestWifiScan.java

/**
 * Try to launch Wifi Connecter with {@link #hostspot}. Prompt user to download if Wifi Connecter is not installed.
 * @param activity//from ww w .ja v  a2  s.c om
 * @param hotspot
 */
private static void launchWifiConnecter(final Activity activity, final ScanResult hotspot) {
    final Intent intent = new Intent("com.farproc.wifi.connecter.action.CONNECT_OR_EDIT");
    intent.putExtra("com.farproc.wifi.connecter.extra.HOTSPOT", hotspot);
    try {
        activity.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        // Wifi Connecter Library is not installed.
        Toast.makeText(activity, "Wifi Connecter is not installed.", Toast.LENGTH_LONG).show();
        downloadWifiConnecter(activity);
    }
}

From source file:Main.java

public static void start(Activity activity, Fragment fragment, Class<?> cls, Bundle extras, int req_code,
        int enterAnim, int exitAnim) {
    if (null != activity) {
        Intent intent = new Intent(activity, cls);
        if (null != extras) {
            intent.putExtras(extras);//from w  w w .j  a v a  2s.  c  o  m
        }

        if (REQUEST_CODE_INVALID == req_code) {
            activity.startActivity(intent);
        } else {
            activity.startActivityForResult(intent, req_code);
        }

        if (0 != enterAnim || 0 != exitAnim) {
            activity.overridePendingTransition(enterAnim, exitAnim);
        }
    } else if (null != fragment) {
        activity = fragment.getActivity();

        if (null != activity) {
            Intent intent = new Intent(activity, cls);
            if (null != extras) {
                intent.putExtras(extras);
            }
            if (REQUEST_CODE_INVALID == req_code) {
                fragment.startActivity(intent);
            } else {
                fragment.startActivityForResult(intent, req_code);
            }

            if (0 != enterAnim || 0 != exitAnim) {
                activity.overridePendingTransition(enterAnim, exitAnim);
            }
        }
    }
}

From source file:com.ihelpoo.app.common.QQWeiboHelper.java

/**
* ?/*  www. ja va 2  s . co  m*/
* @param activity
* @param title
* @param url
*/
public static void shareToQQ(Activity activity, String title, String url) {
    String URL = Share_URL;
    try {
        URL += "&title=" + URLEncoder.encode(title, HTTP.UTF_8) + "&url=" + URLEncoder.encode(url, HTTP.UTF_8)
                + "&appkey=" + Share_AppKey + "&source=" + Share_Source + "&site=" + Share_Site;
    } catch (Exception e) {
        e.printStackTrace();
    }
    Uri uri = Uri.parse(URL);
    activity.startActivity(new Intent(Intent.ACTION_VIEW, uri));
}

From source file:Main.java

public static void openActivity(Activity activity, Class<?> pClass, String pAction, Bundle pBundle,
        int requestCode) {
    if (null == activity)
        return;//from w w w.  j  a  v  a 2 s .c  om

    Intent intent = new Intent(pAction);
    intent.setClass(activity, pClass);
    if (pBundle != null) {
        intent.putExtras(pBundle);
    }

    if (requestCode < 0) {
        activity.startActivity(intent);
    } else {
        activity.startActivityForResult(intent, requestCode);
    }
}

From source file:Main.java

public static boolean startActivity(Activity a, String packageName, Bundle args, int flags) {
    PackageManager pm = a.getPackageManager();
    boolean result = true;
    try {//from  ww w . j  a va  2s .  c o  m
        Intent intent = pm.getLaunchIntentForPackage(packageName);
        if (null != intent) {
            intent.addFlags(flags);
            if (args != null)
                intent.putExtras(args);
            a.startActivity(intent);
        }
    } catch (Exception e) {
        Log.e(a.getClass().getName(), e.getMessage(), e);
        result = false;
    }
    return result;
}

From source file:Main.java

private static void organizeAndStart(Activity activity, Class<?> classes, Map<String, String> paramMap) {
    intent = new Intent(activity, classes);
    if (null != paramMap) {
        Set<String> set = paramMap.keySet();
        for (Iterator<String> iterator = set.iterator(); iterator.hasNext();) {
            String key = iterator.next();
            intent.putExtra(key, paramMap.get(key));
        }/*from  ww w.j  av  a 2s  .  com*/
    }
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    activity.startActivity(intent);
}

From source file:com.ephemeraldreams.gallyshuttle.ui.ScheduleActivity.java

/**
 * Launch ScheduleActivity with specified schedule id.
 *
 * @param activity   Activity to launch from.
 * @param scheduleId Schedule to display.
 *//*from w w  w . j a va2 s .  c  o  m*/
public static void launchActivity(Activity activity, int scheduleId) {
    Intent intent = new Intent(activity, ScheduleActivity.class);
    intent.putExtra(EXTRA_SCHEDULE, SCHEDULE_IDS[scheduleId]);
    activity.startActivity(intent);
}