Example usage for android.app Fragment startActivity

List of usage examples for android.app Fragment startActivity

Introduction

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

Prototype

public void startActivity(Intent intent) 

Source Link

Document

Call Activity#startActivity(Intent) from the fragment's containing Activity.

Usage

From source file:Main.java

/**
 * Allow to show map//from  ww  w .j  av a  2s .c om
 */
public static void actionShowMap(Fragment f, String name, String lattitude, String longitude) {
    final String uri = "geo:0,0?q=" + lattitude + "," + longitude + " (" + name + ")";
    f.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
}

From source file:Main.java

@SuppressLint("NewApi")
public static void sendSchemeAddMediaStack(Fragment context, String mediaActivityUrl, String url,
        Bundle bundle) {/* w  ww  . j  a  v  a 2  s  .c  o m*/
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(mediaActivityUrl));
    intent.addFlags(67108864);
    context.startActivity(intent);
    intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
    if (bundle != null) {
        intent.putExtras(bundle);
    }

    context.startActivity(intent);
}

From source file:org.alfresco.mobile.android.platform.intent.BaseActionUtils.java

public static void openIn(Fragment fr, File myFile, String mimeType) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri data = Uri.fromFile(myFile);/*w ww . j  a  v a 2  s.c  o  m*/
    intent.setDataAndType(data, mimeType.toLowerCase());

    try {
        fr.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        AlfrescoNotificationManager.getInstance(fr.getActivity()).showAlertCrouton(fr.getActivity(),
                R.string.error_unable_open_file);
    }
}

From source file:org.alfresco.mobile.android.platform.intent.BaseActionUtils.java

/**
 * Allow to send a link to other application installed in the device.
 * //w w w  .  j a va  2s .c o m
 * @param fr
 * @param url
 */
public static void actionShareLink(Fragment fr, String url) {
    try {
        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("text/plain");
        i.putExtra(Intent.EXTRA_SUBJECT, R.string.share_url_long);
        i.putExtra(Intent.EXTRA_TEXT, url);
        fr.startActivity(Intent.createChooser(i, fr.getActivity().getText(R.string.share_url)));
    } catch (ActivityNotFoundException e) {
        AlfrescoNotificationManager.getInstance(fr.getActivity()).showAlertCrouton(fr.getActivity(),
                R.string.error_unable_share_link);
    }
}

From source file:Main.java

@SuppressLint("NewApi")
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);//w  w w .  ja  va2 s  .co m
    }

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

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

    context.startActivity(intent);
}

From source file:org.alfresco.mobile.android.platform.intent.BaseActionUtils.java

/**
 * Allow user to share a file with other applications.
 * //w  w  w .  j a va 2 s.  co  m
 * @param fr
 * @param contentFile
 */
public static void actionShareContent(Fragment fr, File contentFile) {
    try {
        Intent i = new Intent(Intent.ACTION_SEND);
        i.putExtra(Intent.EXTRA_SUBJECT, contentFile.getName());
        i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(contentFile));
        i.setType(MimeTypeManager.getInstance(fr.getActivity()).getMIMEType(contentFile.getName()));
        fr.startActivity(Intent.createChooser(i, fr.getActivity().getText(R.string.share_content)));
    } catch (ActivityNotFoundException e) {
        AlfrescoNotificationManager.getInstance(fr.getActivity()).showAlertCrouton(fr.getActivity(),
                R.string.error_unable_share_content);
    }
}

From source file:net.sf.diningout.app.ui.FriendsFragment.java

private static void sendInvite(List<String> to, Fragment frag) {
    Intent intent = new Intent(ACTION_SENDTO, Uris.mailto(to, null, null,
            frag.getString(R.string.invite_subject), frag.getString(R.string.invite_body)));
    if (Intents.hasActivity(frag.getActivity(), intent)) {
        frag.startActivity(intent);
    }// w  ww .  ja v a  2 s . co  m
}