List of usage examples for android.content Intent setAction
public @NonNull Intent setAction(@Nullable String action)
From source file:Main.java
public static void sendBroadcast(Context context, String filter, String name, long value) { Intent intent = new Intent(); intent.putExtra(name, value);//from w w w . j ava 2s . co m intent.setAction(filter); context.sendBroadcast(intent); }
From source file:Main.java
public static void sendBroadcast(Context context, String filter, String name, int value) { Intent intent = new Intent(); intent.putExtra(name, value);//w w w . j a v a 2s. co m intent.setAction(filter); context.sendBroadcast(intent); }
From source file:Main.java
private static void syncContactHiResPhoto(Context context, long rawContactId) { final String serviceName = "com.google.android.syncadapters.contacts." + "SyncHighResPhotoIntentService"; final String servicePackageName = "com.google.android.syncadapters.contacts"; final Uri uri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); final Intent intent = new Intent(); intent.setClassName(servicePackageName, serviceName); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(uri, RawContacts.CONTENT_ITEM_TYPE); try {/*from w w w . j a v a 2 s. co m*/ context.startService(intent); } catch (Exception e) { } }
From source file:Main.java
public static void sendBroadcast(Context context, String filter) { if (context == null) { return;/*from w ww. j a v a2 s . com*/ } Intent intent = new Intent(); intent.setAction(filter); if (mLocalBroadcastManager == null) { getLocalBroadcastManager(context.getApplicationContext()); } mLocalBroadcastManager.sendBroadcast(intent); }
From source file:Main.java
public static void sendBroadcast(Context context, String filter, Bundle bundle) { if (context == null) { return;// ww w .j a va2 s. co m } Intent intent = new Intent(); intent.setAction(filter); intent.putExtras(bundle); if (mLocalBroadcastManager == null) { getLocalBroadcastManager(context.getApplicationContext()); } mLocalBroadcastManager.sendBroadcast(intent); }
From source file:Main.java
public static void sendBroadcast(Context context, String filter, String bundleName, Bundle bundle) { if (context == null) { return;/* w ww . j a v a2 s .c o m*/ } Intent intent = new Intent(); intent.setAction(filter); intent.putExtra(bundleName, bundle); if (mLocalBroadcastManager == null) { getLocalBroadcastManager(context.getApplicationContext()); } mLocalBroadcastManager.sendBroadcast(intent); }
From source file:Main.java
public static void sendBroadcast(Context context, String filter, String name, Serializable serializable) { Intent intent = new Intent(); intent.putExtra(name, serializable); intent.setAction(filter); context.sendBroadcast(intent);//www . ja v a2s . c om }
From source file:Main.java
public static void installApk(Context context, File file) { if (context != null && isFileExists(file)) { Uri uri = Uri.fromFile(new File(file.getAbsolutePath())); Intent installIntent = new Intent(); installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); installIntent.setAction(Intent.ACTION_VIEW); String type = "application/vnd.android.package-archive"; installIntent.putExtra("loadapk", "loadapk"); installIntent.setDataAndType(uri, type); context.startActivity(installIntent); }//from w w w .j av a2 s.c o m }
From source file:Main.java
public static void install(Context context, String fileName) { if (TextUtils.isEmpty(fileName) || context == null) { return;/* w ww . j a v a 2s. co m*/ } try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive"); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static String unInstallBySys(Context context, String pckName) { Intent intent = new Intent(); Uri uri = Uri.parse("package:" + pckName); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Intent.ACTION_DELETE); intent.setData(uri);//from ww w .j a v a2 s . com context.startActivity(intent); return null; }