List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
From source file:com.airbop.client.GCMIntentService.java
private static void generateImageNotification(Context context, String title, String message, String url, String image_url, String large_icon) { // The bitmap to download Bitmap message_bitmap = null;/*from w w w . j a v a2 s . c o m*/ // Should we download the image? if ((image_url != null) && (!image_url.equals(""))) { message_bitmap = AirBopImageDownloader.downloadBitmap(image_url); } // If we didn't get the image, we're out of here if (message_bitmap == null) { generateNotification(context, title, message, url, large_icon); return; } int icon = R.drawable.ic_stat_gcm; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if ((title == null) || (title.equals(""))) { title = context.getString(R.string.app_name); } Intent notificationIntent = null; if ((url == null) || (url.equals(""))) { //just bring up the app notificationIntent = new Intent(context, DemoActivity.class); } else { //Launch the URL notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.setData(Uri.parse(url)); notificationIntent.addCategory(Intent.CATEGORY_BROWSABLE); } // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); Notification notification = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(message).setContentIntent(intent).setSmallIcon(icon) .setLargeIcon(decodeImage(large_icon)).setWhen(when) .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(message_bitmap)).build(); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:com.enstage.wibmo.sdk.inapp.InAppInitActivity.java
public static void startInAppReadinessCheck(Activity activity) { Log.d(TAG, "startInAppReadinessCheck"); String targetAppPackage = WibmoSDK.getWibmoIntentActionPackage(); Intent intent = new Intent(targetAppPackage + ".ReadinessChecker"); intent.addCategory(Intent.CATEGORY_DEFAULT); if (WibmoSDK.getWibmoAppPackage() != null) { intent.setPackage(WibmoSDK.getWibmoAppPackage()); }/*from w ww . j a v a 2 s . c o m*/ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); //causes to iap to be cancelled when app returned by icon launch activity.startActivityForResult(intent, REQUEST_CODE_IAP_READY); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppStateObj.java
public static Intent getLaunchIntent(Context context, SignedObj obj) { JSONObject content = obj.getJson();/*ww w.j a v a 2s .c o m*/ if (DBG) Log.d(TAG, "Getting launch intent for " + content); Uri appFeed; if (content.has(DbObject.CHILD_FEED_NAME)) { Log.d(TAG, "using child feed"); appFeed = Feed.uriForName(content.optString(DbObject.CHILD_FEED_NAME)); } else { Log.d(TAG, "using obj feed"); appFeed = Feed.uriForName(content.optString(DbObjects.FEED_NAME)); } String arg = content.optString(ARG); String state = content.optString(STATE); String appId = obj.getAppId(); // TODO: Hack for deprecated launch method if (appId.equals(DungBeetleContentProvider.SUPER_APP_ID)) { appId = content.optString(PACKAGE_NAME); } if (DBG) Log.d(TAG, "Preparing launch of " + appId + " on " + appFeed); Intent launch = new Intent(); if (content.has(AppReferenceObj.OBJ_INTENT_ACTION)) { launch.setAction(content.optString(AppReferenceObj.OBJ_INTENT_ACTION)); } else { launch.setAction(Intent.ACTION_MAIN); } if (state != null) { launch.putExtra("mobisocial.db.STATE", state); } launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.putExtra(AppState.EXTRA_FEED_URI, appFeed); // TODO: hack until this obj is available in 'related' query. launch.putExtra("obj", content.toString()); // TODO: this is better. launch.putExtra(Musubi.EXTRA_OBJ_HASH, obj.getHash()); if (arg != null) { launch.putExtra(AppState.EXTRA_APPLICATION_ARGUMENT, arg); } // TODO: optimize! List<ResolveInfo> resolved = context.getPackageManager().queryIntentActivities(launch, 0); for (ResolveInfo r : resolved) { ActivityInfo activity = r.activityInfo; if (activity.packageName.equals(appId)) { launch.setClassName(activity.packageName, activity.name); launch.putExtra("mobisocial.db.PACKAGE", activity.packageName); return launch; } } Intent market = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appId)); return market; }
From source file:com.enstage.wibmo.sdk.inapp.InAppInitActivity.java
public static void startInAppFlowInApp(Activity activity, W2faInitRequest w2faInitRequest, W2faInitResponse w2faInitResponse) { Intent intent = new Intent(WibmoSDK.getWibmoIntentActionPackage() + ".InApp"); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra("W2faInitRequest", w2faInitRequest); intent.putExtra("W2faInitResponse", w2faInitResponse); /*/*from ww w . j ava 2 s . c om*/ String targetAppPackage = WibmoSDK.getWibmoPackage(); boolean flag = WibmoSDK.isPackageExisted(activity, targetAppPackage); if (flag==false) { WibmoSDK.showDownloadDialog(activity); } */ if (readyPackage != null) { intent.setPackage(readyPackage); } intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); //causes to iap to be cancelled when app returned by icon launch activity.startActivityForResult(intent, WibmoSDK.REQUEST_CODE_IAP_2FA); }
From source file:com.enstage.wibmo.sdk.inapp.InAppInitActivity.java
public static void startInAppFlowInApp(Activity activity, WPayInitRequest wPayInitRequest, WPayInitResponse wPayInitResponse) { Intent intent = new Intent(WibmoSDK.getWibmoIntentActionPackage() + ".InApp"); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra("WPayInitRequest", wPayInitRequest); intent.putExtra("WPayInitResponse", wPayInitResponse); /*//from w ww . j a v a 2s . c o m String targetAppPackage = WibmoSDK.getWibmoPackage(); boolean flag = WibmoSDK.isPackageExisted(activity, targetAppPackage); if (flag==false) { WibmoSDK.showDownloadDialog(activity); } */ if (readyPackage != null) { intent.setPackage(readyPackage); } intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); //causes to iap to be cancelled when app returned by icon launch activity.startActivityForResult(intent, WibmoSDK.REQUEST_CODE_IAP_PAY); }
From source file:free.yhc.netmbuddy.utils.Utils.java
public static void resumeApp() { Intent intent = new Intent(Utils.getAppContext(), YTMPActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Utils.getAppContext().startActivity(intent); }
From source file:Main.java
private static void shareImageOnFacebook(String imagePath, Context context) { Log.d("CitationsManager-ShareOnFb", "sharing the image " + imagePath); Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("image/*"); // shareIntent.putExtra(Intent.EXTRA_TEXT, "www.google.com"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath))); PackageManager pm = context.getPackageManager(); List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0); for (final ResolveInfo app : activityList) { Log.d("CitationsManager-ShareOnFb", app.activityInfo.name); if ((app.activityInfo.name).contains("com.facebook") && !(app.activityInfo.name).contains("messenger") && !(app.activityInfo.name).contains("pages")) { final ActivityInfo activity = app.activityInfo; final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name); shareIntent.addCategory(Intent.CATEGORY_LAUNCHER); shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); shareIntent.setComponent(name); context.startActivity(shareIntent); break; }//from ww w. ja v a 2 s .c om } }
From source file:br.com.arlsoft.pushclient.PushClientModule.java
public static Intent getLauncherIntent(Bundle extras) { TiApplication appContext = TiApplication.getInstance(); PackageManager pm = appContext.getPackageManager(); Intent launch = pm.getLaunchIntentForPackage(appContext.getPackageName()); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (extras != null && !extras.isEmpty()) { launch.putExtra(PROPERTY_EXTRAS, extras); }//from w ww .j av a 2 s . c o m return launch; }
From source file:com.farmerbb.secondscreen.util.U.java
public static String uiRefreshCommand2(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); // For better reliability, we execute the UI refresh while on the home screen Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.addCategory(Intent.CATEGORY_DEFAULT); homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(homeIntent);/*from w ww .ja va 2 s .com*/ // Kill all background processes, in order to fully refresh UI PackageManager pm = context.getPackageManager(); List<ApplicationInfo> packages = pm.getInstalledApplications(0); for (ApplicationInfo packageInfo : packages) { if (!packageInfo.packageName.equalsIgnoreCase(context.getPackageName())) am.killBackgroundProcesses(packageInfo.packageName); } // Get launcher package name final ResolveInfo mInfo = pm.resolveActivity(homeIntent, 0); return "sleep 1 && am force-stop " + mInfo.activityInfo.applicationInfo.packageName; }
From source file:com.test.onesignal.MainOneSignalClassRunner.java
private static void AddLauncherIntentFilter() { Intent launchIntent = new Intent(Intent.ACTION_MAIN); launchIntent.setPackage("com.onesignal.example"); launchIntent.addCategory(Intent.CATEGORY_LAUNCHER); ResolveInfo resolveInfo = new ResolveInfo(); resolveInfo.activityInfo = new ActivityInfo(); resolveInfo.activityInfo.packageName = "com.onesignal.example"; resolveInfo.activityInfo.name = "MainActivity"; RuntimeEnvironment.getRobolectricPackageManager().addResolveInfoForIntent(launchIntent, resolveInfo); }