List of usage examples for android.content Intent setPackage
public @NonNull Intent setPackage(@Nullable String packageName)
From source file:Main.java
public static void dump(Context context) { Intent intent = new Intent(DUMP_ACTION); intent.setPackage(context.getPackageName()); context.sendBroadcast(intent);//from w ww .j av a2 s . c o m }
From source file:Main.java
public static Intent getShowOrbotStartIntent() { Intent intent = new Intent(ACTION_START_TOR); intent.setPackage(ORBOT_PACKAGE_NAME); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return intent; }
From source file:Main.java
public static boolean gotoGoogleMarket(Activity activity, String pck) { try {/* w ww .ja v a2 s . co m*/ Intent intent = new Intent(); intent.setPackage("com.android.vending"); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + pck)); activity.startActivity(intent); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
From source file:Main.java
static void passDownload(String linkToDownload, String SAVE, String notificationTitle, String fileName, String fileType, String userName, Context mContext) { Intent downloadIntent = new Intent(); downloadIntent.setPackage("com.ihelp101.instagram"); downloadIntent.setAction("com.ihelp101.instagram.PASS"); downloadIntent.putExtra("URL", linkToDownload); downloadIntent.putExtra("SAVE", SAVE); downloadIntent.putExtra("Notification", notificationTitle); downloadIntent.putExtra("Filename", fileName); downloadIntent.putExtra("Filetype", fileType); downloadIntent.putExtra("User", userName); mContext.startService(downloadIntent); }
From source file:Main.java
public static boolean isApkInstalled(Context context) { PackageManager pm = context.getPackageManager(); // Intent intent = new Intent(Intent.ACTION_MAIN, null); // intent.addCategory(Intent.CATEGORY_DEFAULT); // intent.setPackage("com.cnnct.zfwgpy"); Intent intent = new Intent(); intent.setPackage("com.cnnct.zfwgpy"); List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0); if (apps != null && apps.size() > 0) { return true; }/*from ww w . jav a2 s. c o m*/ return false; }
From source file:Main.java
public static void requestHiddenServiceOnPort(Activity activity, int port) { Intent intent = new Intent(ACTION_REQUEST_HS); intent.setPackage(ORBOT_PACKAGE_NAME); intent.putExtra("hs_port", port); activity.startActivityForResult(intent, HS_REQUEST_CODE); }
From source file:Main.java
private 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);/*from w w w.j a v a2 s . c o m*/ Log.d(TAG, "Intent: " + intent.getAction() + " package: " + packageName); } return list; }
From source file:Main.java
public static ArrayList<String> getActivities(Context ctx) { ArrayList<String> result = new ArrayList<String>(); Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.setPackage(ctx.getPackageName()); for (ResolveInfo info : ctx.getPackageManager().queryIntentActivities(intent, 0)) { result.add(info.activityInfo.name); }//from ww w . j av a2 s .c o m return result; }
From source file:Main.java
public static void sendBroadcast(Context context, String packageName, String action) { Intent intent = new Intent(action); intent.setPackage(packageName); context.sendBroadcast(intent);/* w ww . j av a 2 s . co m*/ }
From source file:Main.java
/** * Gets an {@link Intent} for starting Orbot. Orbot will reply with the * current status to the {@code packageName} of the app in the provided * {@link Context} (i.e. {@link Context#getPackageName()}. *///from w w w. j ava 2 s . co m public static Intent getOrbotStartIntent(Context context) { Intent intent = new Intent(ACTION_START); intent.setPackage(ORBOT_PACKAGE_NAME); intent.putExtra(EXTRA_PACKAGE_NAME, context.getPackageName()); return intent; }