Example usage for android.app Activity getPackageManager

List of usage examples for android.app Activity getPackageManager

Introduction

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

Prototype

@Override
    public PackageManager getPackageManager() 

Source Link

Usage

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * View facebook user page./*www  .  ja v  a  2  s.co m*/
 *
 * @param activity context
 * @param userId   user profile ID
 */
public static void launchFacebookIntent(Activity activity, String userId) {
    StringBuilder sb = new StringBuilder("https:www.facebook.com/").append(userId);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(intent);
    }
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * View Instagram profile/*from www. j av  a2  s  .co m*/
 *
 * @param activity context
 * @param userId   instagram user id
 */
public static void launchInstagramIntent(Activity activity, String userId) {
    StringBuilder sb = new StringBuilder("https:instagram.com/_u/").append(userId);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(intent);
    }
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * Launch a twitch profile link.//from   w  w  w  .j  ava 2s  .c o  m
 *
 * @param activity context
 * @param address  http address
 */
public static void launchTwitchIntent(Activity activity, String address) {
    StringBuilder sb = new StringBuilder("http:www.twitch.tv/").append(address);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(intent);
    } else {
        Toast.makeText(activity, "Invalid link", Toast.LENGTH_LONG).show();
    }
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * View Address in maps/*from  ww w.j  a v a 2  s. c o  m*/
 *
 * @param activity      context
 * @param actionAddress location
 */
public static void launchAddressIntent(Activity activity, String actionAddress) {
    StringBuilder sb = new StringBuilder("geo:0,0?q=").append(actionAddress);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(intent);
    }
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * Launch a playstation network profile link.
 *
 * @param activity context//from ww  w.j  av  a 2s .c o  m
 * @param address  address
 */
public static void launchPlaystationNetworkIntent(Activity activity, String address) {
    StringBuilder sb = new StringBuilder("http:psnprofiles.com/").append(address);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(intent);
    } else {
        Toast.makeText(activity, "Invalid link", Toast.LENGTH_LONG).show();
    }
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * View Spotify profile//  w w  w.j ava  2  s. co m
 *
 * @param activity      context
 * @param actionAddress user endpoint
 */
public static void launchSpotifyIntent(Activity activity, String actionAddress) {
    StringBuilder sb = new StringBuilder("spotify:user:").append(actionAddress);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(intent);
    }
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * View Twitter profile// w ww  .j  a  va2  s. c o  m
 *
 * @param activity context
 * @param userId   user profile ID
 */
public static void launchTwitterIntent(Activity activity, String userId) {
    StringBuilder sb = new StringBuilder("twitter://user?screen_name=").append(userId);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (intent.resolveActivity(activity.getPackageManager()) == null) {
        intent.setData(Uri.parse("https://mobile.twitter.com/" + userId));
    }
    activity.startActivity(intent);
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * Launch a steam profile link.//  w  w w .  java2 s .c  om
 *
 * @param activity context
 * @param address  http address
 */
public static void launchSteamIntent(Activity activity, String address) {
    StringBuilder sb = new StringBuilder("http:steamcommunity.com/id/").append(address);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(intent);
    } else {
        Toast.makeText(activity, "Invalid link", Toast.LENGTH_LONG).show();
    }
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * Launch Email Intent./*from  w  ww .j  a  v  a2s.  c  om*/
 *
 * @param activity context
 * @param address  to send to
 */
public static void launchEmailIntent(Activity activity, String address) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:"));

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(intent);
    }
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * View Reddit profile or subreddit/*ww w . j  a v  a  2 s .  co m*/
 *
 * @param activity      context
 * @param actionAddress endpoint
 */
public static void launchRedditIntent(Activity activity, String actionAddress) {
    StringBuilder sb = new StringBuilder("https://reddit.com").append(actionAddress);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sb.toString()));

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(intent);
    }
}