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 SnapChant profile/*from   w  ww.  jav a  2 s.c o  m*/
 *
 * @param activity      context
 * @param actionAddress location
 */
public static void launchSnapChatIntent(Activity activity, String actionAddress) {
    StringBuilder sb = new StringBuilder("http:snapchat.com/add/").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 nintendo network profile link.
 *
 * @param activity context//w  w w . j a  va2s. c o  m
 * @param address  address
 */
public static void launchNintendoNetworkIntent(Activity activity, String address) {
    StringBuilder sb = new StringBuilder("http:miiverse.nintendo.net/users/").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 google plus profile/*from   www .  j a  va 2  s.  c o m*/
 *
 * @param activity context
 * @param userId   plus user id
 */
public static void launchGooglePlusIntent(Activity activity, String userId) {
    StringBuilder sb = new StringBuilder("https://plus.google.com/").append(userId).append("/posts");
    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 xbox live profile link.//from  w w w  .  j a v  a  2s . c o m
 *
 * @param activity context
 * @param address  http address
 */
public static void launchXboxLiveIntent(Activity activity, String address) {
    StringBuilder sb = new StringBuilder("http:live.xbox.com/en-US/Profile?Gamertag=").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 a lol profile link./* ww  w.  ja  v  a  2s. c  om*/
 *
 * @param activity context
 * @param address  address
 */
public static void launchLeagueOfLegendsIntent(Activity activity, String address) {
    StringBuilder sb = new StringBuilder("http:boards.na.leagueoflegends.com/en/player/NA/").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.forrestguice.suntimeswidget.AlarmDialog.java

public static void scheduleAlarm(Activity context, String label, Calendar calendar) {
    if (calendar == null)
        return;//w w  w  .  j a  va2  s .  c o  m

    Calendar alarm = new GregorianCalendar(TimeZone.getDefault());
    alarm.setTimeInMillis(calendar.getTimeInMillis());
    int hour = alarm.get(Calendar.HOUR_OF_DAY);
    int minutes = alarm.get(Calendar.MINUTE);

    Intent alarmIntent = new Intent(AlarmClock.ACTION_SET_ALARM);
    alarmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    alarmIntent.putExtra(AlarmClock.EXTRA_MESSAGE, label);
    alarmIntent.putExtra(AlarmClock.EXTRA_HOUR, hour);
    alarmIntent.putExtra(AlarmClock.EXTRA_MINUTES, minutes);

    if (alarmIntent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(alarmIntent);
    }
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * Send SMS to phone number on Hangouts.
 *
 * @param activity      context/*from w ww . j av  a 2 s.com*/
 * @param actionAddress to contactId
 */
public static void launchHangoutsIntent(Activity activity, String actionAddress) {
    StringBuilder sb = new StringBuilder("content://com.android.contacts/data/").append(actionAddress);
    Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(sb.toString()));
    intent.setPackage("com.google.android.talk");

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

From source file:com.Trigger.SmsSendingPlugin.java

@Override
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext)
        throws JSONException {

    if (action.equals(ACTION_HAS_SMS_POSSIBILITY)) {

        Activity ctx = this.cordova.getActivity();
        if (ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, true));
        } else {//from  w ww .j a  v a  2s  .c om
            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, false));
        }
        return true;
    } else if (action.equals(ACTION_SEND_SMS)) {
        try {
            String phoneNumber = args.getString(0);
            String message = args.getString(1);
            this.sendSMS(phoneNumber, message);

            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
        } catch (JSONException ex) {
            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, ex.getMessage()));
        }
        return true;
    }
    return false;
}

From source file:com.shareyourproxy.IntentLauncher.java

/**
 * View Invite friends// w  ww.j  a v a2  s.co m
 *
 * @param activity context
 */
public static void launchInviteFriendIntent(Activity activity) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.share_your_proxy));
    intent.putExtra(Intent.EXTRA_TEXT, activity.getString(R.string.invite_friend_content));
    if (intent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(createChooser(intent, activity.getString(R.string.invite_a_friend)));
    }
}

From source file:com.manotaurgames.castro.CastFragment.java

private String getCastAppId() {
    if (mCastAppIdRes != null) {
        return getString(mCastAppIdRes);
    }//from  w w  w . j  a v  a 2 s.c  o m
    Activity a = getActivity();
    try {
        ApplicationInfo ai = a.getPackageManager().getApplicationInfo(a.getPackageName(),
                PackageManager.GET_META_DATA);
        return (String) ai.metaData.get("GoogleCastId");
    } catch (NameNotFoundException e) {
        throw new RuntimeException(e);
    }
}