Java Code Examples for android.support.v4.app.Fragment#startActivity()

The following examples show how to use android.support.v4.app.Fragment#startActivity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemeDispatcher.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public static void sendScheme(Fragment context, String url, Bundle bundle, boolean clearTop, int flag) {

        Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
        if(bundle != null) {
            intent.putExtras(bundle);
        }

        if(clearTop) {
            intent.addFlags(67108864);
        }

        if(flag != 0) {
            intent.setFlags(flag);
        }

        context.startActivity(intent);
    }
 
Example 2
Source File: ContentActivity.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void viewAssignment(Fragment fragment, Assignment assignment, ArrayList<Attachment> attachments, String mdText) {
    Intent intent = new Intent(fragment.getContext(), ContentActivity.class);
    intent.putExtra(Constants.EXTRA_FRAGMENT, Constants.VALUE_FRAGMENT_ASSIGNMENT_VIEWER);
    intent.putExtra(Constants.EXTRA_MODEL, (Serializable) assignment);
    intent.putParcelableArrayListExtra(Constants.EXTRA_ATTACHMENTS, attachments);
    intent.putExtra(Constants.EXTRA_MARKDOWN_CONTENT, mdText);
    fragment.startActivity(intent);
}
 
Example 3
Source File: Flow.java    From Flow with Apache License 2.0 5 votes vote down vote up
private void fromFragment() {
    Fragment fragment = ((Fragment) src);
    if (forResult) {
        fragment.startActivityForResult(intent(fragment.getActivity()), requestCode);
    } else {
        fragment.startActivity(intent(fragment.getActivity()));
    }
}
 
Example 4
Source File: Router.java    From MRouter with Apache License 2.0 5 votes vote down vote up
private void startInFragment(Fragment fragment, boolean isForResult, int requestCode) {
    Class clazz = getClassFromRouter();
    if (clazz == null) {
        return;
    }
    if (isForResult) {
        fragment.startActivityForResult(getIntent(fragment.getActivity(), clazz), requestCode);
    } else {
        fragment.startActivity(getIntent(fragment.getActivity(), clazz));
    }
}
 
Example 5
Source File: Navigator.java    From octoandroid with GNU General Public License v3.0 5 votes vote down vote up
public boolean navigateToDownloadFile(Fragment fragment, String url) {
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        if ((intent.resolveActivity(fragment.getActivity().getPackageManager()) != null)) {
            fragment.startActivity(intent);
            return true;
        }
        return false;
    } catch (NullPointerException e) {
        return false;
    }
}
 
Example 6
Source File: FragmentLauncher.java    From XiaoxiaZhihu with Apache License 2.0 5 votes vote down vote up
public static void launch(Fragment fragment, CommonExtraParam param, int req) {
    Intent it = new Intent(fragment.getActivity(), getTargetActivityClass(param));

    it.putExtra(ICommonFragment.EXTRA_REQ, param);
    if (req == 0) {
        fragment.startActivity(it);
    } else {
        fragment.startActivityForResult(it, req);
    }
}
 
Example 7
Source File: RxFragmentActivityResult.java    From RxActivityResult with Apache License 2.0 5 votes vote down vote up
/**
 * Create new {@link Launchable} from l launch source component({@link Fragment}) of other
 * activity.
 *
 * @param fragment requesting result
 * @return New {@link Launchable} instance.
 */
@CheckResult
public Launchable from(@NonNull final Fragment fragment) {
    return new RxActivityResult.Launcher(rxActivityResult) {
        @Override
        protected void startActivity(Intent intent) {
            fragment.startActivity(intent);
        }
    };
}
 
Example 8
Source File: PermissionFragmentHelper.java    From PermissionHelper with Apache License 2.0 5 votes vote down vote up
/**
 * open android settings screen for your app.
 */
public static void openSettingsScreen(@NonNull Fragment context) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.parse("package:" + context.getContext().getPackageName());
    intent.setData(uri);
    context.startActivity(intent);
}
 
Example 9
Source File: ArticleActivity.java    From Yuan-WanAndroid with Apache License 2.0 3 votes vote down vote up
/**
 * 给没有文章id的调用
 * @param activity
 * @param fragment
 * @param url
 * @param title
 */
public static void startActivityByFragment(Activity activity, Fragment fragment, String url, String title) {
    Intent intent = new Intent(activity, ArticleActivity.class);
    intent.putExtra(Constant.KEY_ARTICLE_URL, url);
    intent.putExtra(Constant.KEY_ARTICLE_TITLE, title);
    fragment.startActivity(intent);
}