List of usage examples for android.content Intent setPackage
public @NonNull Intent setPackage(@Nullable String packageName)
From source file:Main.java
/** * Gets a barebones {@link Intent} for starting Orbot. This is deprecated * in favor of {@link #getOrbotStartIntent(Context)}. *//*from w ww. j a va 2 s .c om*/ @Deprecated public static Intent getOrbotStartIntent() { Intent intent = new Intent(ACTION_START); intent.setPackage(ORBOT_PACKAGE_NAME); return intent; }
From source file:Main.java
public static List<Intent> addIntentsToList(Context context, List<Intent> list, Intent intent) { List<ResolveInfo> resInfo = context.getPackageManager().queryIntentActivities(intent, 0); for (ResolveInfo resolveInfo : resInfo) { String packageName = resolveInfo.activityInfo.packageName; Intent targetedIntent = new Intent(intent); targetedIntent.setPackage(packageName); list.add(targetedIntent);/*ww w . j av a2s . c o m*/ } return list; }
From source file:Main.java
public static Intent buildIntent(final Context context, String action, String data) { Intent intent = new Intent(action); intent.putExtra("what", data); intent.setPackage(context.getPackageName()); return intent; }
From source file:Main.java
public static void startActivityByPackageName(Context context, String packagename) { try {//from w w w. j a v a 2s .c o m Intent intent = new Intent(); intent.setPackage(packagename); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void addToPocket(Context context, String url, String tweetStatusId) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setPackage(PACKAGE); intent.setType(MIME_TYPE);//from w w w. j a v a2s . c o m intent.putExtra(Intent.EXTRA_TEXT, url); if (tweetStatusId != null && tweetStatusId.length() > 0) { intent.putExtra(EXTRA_TWEET_STATUS_ID, tweetStatusId); } intent.putExtra(EXTRA_SOURCE_PACKAGE, context.getPackageName()); context.startActivity(intent); }
From source file:Main.java
/** * Start intent using an activity inside this app. This method is useful if you are certain * that the intent can be handled inside this app, and you care about shaving milliseconds. *//*from w ww .j a va 2 s.c om*/ public static void startActivityInApp(Context context, Intent intent) { String packageName = context.getPackageName(); intent.setPackage(packageName); context.startActivity(intent); }
From source file:Main.java
public static Intent getOrbotStartIntent() { Intent intent = new Intent(ACTION_START); intent.setPackage(ORBOT_PACKAGE_NAME); return intent; }
From source file:Main.java
/** * Returns an intent to display the message identified by the provided URI in K-9 Mail. * * @param context// ww w . j a va 2s .c o m * Used to retrieve the package manager. * @param emailUri * The URI that identified the message to be displayed. * * @return An intent to start K-9 Mail's main activity, or {@code null} in case of an error. */ public static final Intent getViewMessageIntent(Context context, String emailUri) { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setPackage(PACKAGE_NAME); intent.setData(Uri.parse(emailUri)); return intent; } catch (Exception e) { return null; } }
From source file:Main.java
/** * Send a broadcast to internal receivers. *///from w ww .j a va 2 s. c om public static void sendToInternal(@NonNull Context cxt, @NonNull Intent intent) { String perm = cxt.getPackageName() + PERM_COMMON_BROADCAST; intent.setPackage(cxt.getPackageName()); // only works on Android 4.0 and higher versions cxt.sendBroadcast(intent, perm); }
From source file:Main.java
public static String getMainProcessName(Context context) { Intent it = new Intent(Intent.ACTION_MAIN); it.setPackage(context.getPackageName()); ResolveInfo info = context.getPackageManager().resolveActivity(it, PackageManager.GET_RESOLVED_FILTER); String processName = null;//from w w w . j a v a 2 s . com if (info != null && info.activityInfo != null) { processName = info.activityInfo.processName; } else { processName = context.getPackageName(); } return processName; }