/** Generate a User Agent */ public static String getUserAgent() { Context context = TramHunterApplication.getContext(); final PackageManager pm = context.getPackageManager(); String packageName = "Unknown"; String packageVersion = "Unknown"; String applicationName = "Unknown"; String androidVersion = android.os.Build.VERSION.RELEASE; if (androidVersion == null) androidVersion = "N/A"; try { packageName = context.getPackageName(); // App info ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); applicationName = (String) pm.getApplicationLabel(ai); // Package info PackageInfo pi = context.getPackageManager().getPackageInfo(packageName, 0); packageVersion = pi.versionName; } catch (NameNotFoundException e) { return "Unknown"; } return String.format("%s/%s (Android %s)", applicationName, packageVersion, androidVersion); }
protected Bitmap cachedResourceIconHelper(String resourceName) { Drawable iconPackIcon = null; String cachedIconString = IconCacheHelper.getPreloadedIconUri(mContext, resourceName); if (cachedIconString == null) { if (ich == null) { ich = new IconCacheHelper(mContext); Tools.HangarLog("Loading new IconCacheHelper instance"); } if (resourceName.equals(Settings.MORE_APPS_PACKAGE)) { iconPackIcon = mContext.getResources().getDrawable(Settings.MORE_APPS_DRAWABLE_RESOURCE); IconCacheHelper.preloadIcon( mContext, resourceName, Tools.drawableToBitmap(iconPackIcon), Tools.dpToPx(mContext, Settings.CACHED_ICON_SIZE)); } else { Intent intent = mContext.getPackageManager().getLaunchIntentForPackage(resourceName); ResolveInfo rInfo = mContext.getPackageManager().resolveActivity(intent, 0); if (rInfo == null) return null; iconPackIcon = new IconCacheHelper(mContext).getFullResIcon(rInfo.activityInfo, true); IconCacheHelper.preloadIcon( mContext, resourceName, Tools.drawableToBitmap(iconPackIcon), Tools.dpToPx(mContext, Settings.CACHED_ICON_SIZE)); } } if (iconPackIcon == null) { return IconCacheHelper.getPreloadedIcon(mContext, resourceName); } else { return Tools.drawableToBitmap(iconPackIcon); } }
@Override public void onStart() { final Context context = getContext(); mTwilightManager = getLocalService(TwilightManager.class); final PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG); context.registerReceiver(mDockModeReceiver, new IntentFilter(Intent.ACTION_DOCK_EVENT)); context.registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); mConfiguration.setToDefaults(); mDefaultUiModeType = context.getResources().getInteger( com.android.internal.R.integer.config_defaultUiModeType); mCarModeKeepsScreenOn = (context.getResources().getInteger( com.android.internal.R.integer.config_carDockKeepsScreenOn) == 1); mDeskModeKeepsScreenOn = (context.getResources().getInteger( com.android.internal.R.integer.config_deskDockKeepsScreenOn) == 1); mTelevision = context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_TELEVISION) || context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_LEANBACK); mWatch = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH); mNightMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.UI_NIGHT_MODE, UiModeManager.MODE_NIGHT_AUTO); mTwilightManager.registerListener(mTwilightListener, mHandler); publishBinderService(Context.UI_MODE_SERVICE, mService); }
public AppMultiSelectListPreference(Context context, AttributeSet attrs) { super(context, attrs); List<ApplicationInfo> pkgs = context.getPackageManager().getInstalledApplications(PackageManager.PERMISSION_GRANTED); for (int i = 0; i < pkgs.size(); i++) { ApplicationInfo ai = pkgs.get(i); if (context.getPackageManager().getLaunchIntentForPackage(ai.packageName) == null) { continue; } MyApplicationInfo info = new MyApplicationInfo(); info.info = ai; info.label = info.info.loadLabel(getContext().getPackageManager()).toString(); mPackageInfoList.add(info); } List<CharSequence> entries = new ArrayList<CharSequence>(); List<CharSequence> entryValues = new ArrayList<CharSequence>(); Collections.sort(mPackageInfoList, sDisplayNameComparator); for (MyApplicationInfo info : mPackageInfoList) { entries.add(info.label); entryValues.add(info.info.packageName); } MyApplicationInfo info = new MyApplicationInfo(); mEntries = new CharSequence[entries.size()]; mEntryValues = new CharSequence[entries.size()]; entries.toArray(mEntries); entryValues.toArray(mEntryValues); }
public static void updateMenuEntries(Context context, Menu menu, String pkgName) { if (context.getPackageManager().getLaunchIntentForPackage(pkgName) == null) { menu.findItem(R.id.menu_app_launch).setEnabled(false); Drawable icon = menu.findItem(R.id.menu_app_launch).getIcon().mutate(); icon.setColorFilter(Color.GRAY, Mode.SRC_IN); menu.findItem(R.id.menu_app_launch).setIcon(icon); } boolean hasMarketLink = false; try { PackageManager pm = context.getPackageManager(); String installer = pm.getInstallerPackageName(pkgName); if (installer != null) hasMarketLink = installer.equals("com.android.vending") || installer.contains("google"); } catch (Exception e) { } menu.findItem(R.id.menu_app_store).setEnabled(hasMarketLink); try { Resources res = context.createPackageContext("com.android.vending", 0).getResources(); int id = res.getIdentifier("ic_launcher_play_store", "mipmap", "com.android.vending"); Drawable icon = res.getDrawable(id); if (!hasMarketLink) { icon = icon.mutate(); icon.setColorFilter(Color.GRAY, Mode.SRC_IN); } menu.findItem(R.id.menu_app_store).setIcon(icon); } catch (Exception e) { } }
public static String getAllApp(Context context) { String result = ""; List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(0); for (PackageInfo i : packages) { if ((i.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { result += i.applicationInfo.loadLabel(context.getPackageManager()).toString() + ","; } } return result.substring(0, result.length() - 1); }
public static void getPackageInfoForUid(Context context, UidCommand cpi) { try { PackageManager pm = context.getPackageManager(); PackageInfo pi = context.getPackageManager().getPackageInfo(pm.getPackagesForUid(cpi.uid)[0], 0); cpi.name = pi.applicationInfo.loadLabel(pm).toString(); cpi.packageName = pi.packageName; } catch (Exception ex) { } }
public static int getClientVersion(Context context) { try { Log.d( TAG, context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode + ""); return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return -1; }
public static String getAppLabel(Context context) { CharSequence label = null; try { label = context .getPackageManager() .getApplicationLabel( context.getPackageManager().getApplicationInfo(context.getPackageName(), 0)); } catch (NameNotFoundException e) { } return label == null ? null : label.toString(); }
/** * Retrieve APP displaying name by it's package name. * * @param ctx * @param pkgName * @return */ public static String getAppName(Context ctx, String pkgName) { try { ApplicationInfo appinfo = ctx.getPackageManager().getApplicationInfo(pkgName, PackageManager.GET_ACTIVITIES); if (appinfo == null) { return pkgName; } return ctx.getPackageManager().getApplicationLabel(appinfo).toString(); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return pkgName; } }
public static void postAppInstalledNotification(Context context, String packageName) { Intent neverShowAgain = new Intent(MAXLOCK_ACTION_NEVER_SHOW_AGAIN); neverShowAgain.setClass(context, NewAppInstalledBroadcastReceiver.class); Intent lockApp = new Intent(MAXLOCK_ACTION_LOCK_APP); lockApp.setClass(context, NewAppInstalledBroadcastReceiver.class); lockApp.putExtra(EXTRA_PACKAGE_NAME, packageName); String appName; try { appName = context .getPackageManager() .getApplicationInfo(packageName, 0) .loadLabel(context.getPackageManager()) .toString(); } catch (PackageManager.NameNotFoundException e) { appName = packageName; } NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setContentTitle(context.getString(R.string.notification_lock_new_app_title)) .setContentText(appName) .setSmallIcon(R.drawable.ic_lock_48dp) .setAutoCancel(true) .addAction( new NotificationCompat.Action( 0, context.getString(R.string.notification_lock_new_app_action_never_again), PendingIntent.getBroadcast( context, 0, neverShowAgain, PendingIntent.FLAG_UPDATE_CURRENT))) .addAction( new NotificationCompat.Action( 0, context.getString(R.string.notification_lock_new_app_action_lock), PendingIntent.getBroadcast( context, 0, lockApp, PendingIntent.FLAG_UPDATE_CURRENT))); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder .setPriority(NotificationCompat.PRIORITY_HIGH) .setCategory(NotificationCompat.CATEGORY_RECOMMENDATION) .setColor(ContextCompat.getColor(context, R.color.accent)); try { builder.setVibrate(new long[0]); } catch (SecurityException e) { e.printStackTrace(); } } NotificationManagerCompat nm = NotificationManagerCompat.from(context); nm.notify(APP_INSTALLED_NOTIFICATION_ID, builder.build()); }
/** Check if this device has a camera */ private boolean checkCameraHardware(Context context) { if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) { // this device has a camera return true; } else if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) { // this device has a front camera return true; } else if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) { // this device has any camera return true; } else { // no camera on this device return false; } }
public String getSettingsBuildNumber() { String buildVersionName; int buildVersion; try { buildVersionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; buildVersion = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { // this should never happen buildVersionName = "Unknown"; buildVersion = -1; } return buildVersionName + " [Build Version: " + buildVersion + "]"; }
public static void init(Context context) { try { ApplicationInfo appInfo = context .getPackageManager() .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); boolean msg = appInfo.metaData.getBoolean("debug"); DEBUG = msg; } catch (Exception e) { DEBUG = false; } pm = context.getPackageManager(); SUPERUSER_PATH = context.getResources().getStringArray(R.array.super_user); }
private static void checkReceiver(Context context, Set<String> allowedReceivers, String action) { PackageManager pm = context.getPackageManager(); String packageName = context.getPackageName(); Intent intent = new Intent(action); intent.setPackage(packageName); List<ResolveInfo> receivers = pm.queryBroadcastReceivers(intent, PackageManager.GET_INTENT_FILTERS); if (receivers.isEmpty()) { throw new IllegalStateException("No receivers for action " + action); } if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "Found " + receivers.size() + " receivers for action " + action); } // make sure receivers match for (ResolveInfo receiver : receivers) { String name = receiver.activityInfo.name; if (!allowedReceivers.contains(name)) { throw new IllegalStateException( "Receiver " + name + " is not set with permission " + GCMConstants.PERMISSION_GCM_INTENTS); } } }
/** * Indicates whether the specified action can be used as an intent. This method queries the * package manager for installed packages that can respond to an intent with the specified action. * If no suitable package is found, this method returns false. * http://android-developers.blogspot.com/2009/01/can-i-use-this-intent.html * * @param context The application's environment. * @param action The Intent action to check for availability. * @return True if an Intent with the specified action can be sent and responded to, false * otherwise. */ public static boolean isIntentAvailable(Context context, String action) { final PackageManager packageManager = context.getPackageManager(); final Intent intent = new Intent(action); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
public AppAdapter(Context context, int textViewResourceId, List<ActivityInfo> objects) { super(context, textViewResourceId, objects); mInflater = LayoutInflater.from(context); mPackageManager = context.getPackageManager(); mTextViewResourceId = textViewResourceId; }
/** * whether packageName is system application * * @param context * @param packageName * @return */ public static boolean isSystemApplication(Context context, String packageName) { if (context == null) { return false; } return isSystemApplication(context.getPackageManager(), packageName); }
/** * Check the {@link PackageManager} if the phone has an application installed to view this type of * attachment. If not, {@link #viewButton} is disabled. This should be done in any place where * attachment.viewButton.setEnabled(enabled); is called. This method is safe to be called from the * UI-thread. */ public void checkViewable() { if (viewButton.getVisibility() == View.GONE) { // nothing to do return; } if (!viewButton.isEnabled()) { // nothing to do return; } try { Uri uri = AttachmentProvider.getAttachmentUriForViewing(mAccount, part.getAttachmentId()); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); intent.addFlags( Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); if (intent.resolveActivity(mContext.getPackageManager()) == null) { viewButton.setEnabled(false); } // currently we do not cache re result. } catch (Exception e) { Log.e( K9.LOG_TAG, "Cannot resolve activity to determine if we shall show the 'view'-button for an attachment", e); } }
/** * returns list of all packages installed * * @return List<String> of all installed packages */ public List<String> getAllPackages() { settingsDB dataSrc = new settingsDB(context); dataSrc.open(); showadv = Boolean.parseBoolean(dataSrc.getSetting("showadv")); boolean tmp = false; List<String> out = new ArrayList<String>(); final PackageManager pm = context.getPackageManager(); List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); allNames.clear(); allEnabled.clear(); for (ApplicationInfo packageInfo : packages) { for (int i = 0; i < MainActivity.CBAllBlackList.length; i++) { if (MainActivity.CBAllBlackList[i].contains(packageInfo.packageName)) { tmp = true; break; } } if (!tmp || showadv) { out.add(packageInfo.packageName); allNames.add(pm.getApplicationLabel(packageInfo).toString()); allEnabled.add(packageInfo.enabled); } allAdv.add(tmp); tmp = false; } dataSrc.close(); return out; }
public boolean validateSignature(Context context, String packageName) { String brand = Build.BRAND; int applicationFlags = context.getApplicationInfo().flags; if (brand.startsWith("generic") && (applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { // We are debugging on an emulator, don't validate package signature. return true; } PackageInfo packageInfo = null; try { packageInfo = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES); } catch (PackageManager.NameNotFoundException e) { return false; } for (Signature signature : packageInfo.signatures) { String hashedSignature = Utility.sha1hash(signature.toByteArray()); if (validAppSignatureHashes.contains(hashedSignature)) { return true; } } return false; }
@Override public void onDownloadFinished(Context context, DownloadsUtil.DownloadInfo info) { File localFile = new File(info.localFilename); if (!localFile.isFile()) return; if (moduleVersion.md5sum != null && !moduleVersion.md5sum.isEmpty()) { try { String actualMd5Sum = HashUtil.md5(localFile); if (!moduleVersion.md5sum.equals(actualMd5Sum)) { Toast.makeText( context, context.getString( R.string.download_md5sum_incorrect, actualMd5Sum, moduleVersion.md5sum), Toast.LENGTH_LONG) .show(); DownloadsUtil.removeById(context, info.id); return; } } catch (Exception e) { Toast.makeText( context, context.getString(R.string.download_could_not_read_file, e.getMessage()), Toast.LENGTH_LONG) .show(); DownloadsUtil.removeById(context, info.id); return; } } PackageManager pm = context.getPackageManager(); PackageInfo packageInfo = pm.getPackageArchiveInfo(info.localFilename, 0); if (packageInfo == null) { Toast.makeText(context, R.string.download_no_valid_apk, Toast.LENGTH_LONG).show(); DownloadsUtil.removeById(context, info.id); return; } if (!packageInfo.packageName.equals(moduleVersion.module.packageName)) { Toast.makeText( context, context.getString( R.string.download_incorrect_package_name, packageInfo.packageName, moduleVersion.module.packageName), Toast.LENGTH_LONG) .show(); DownloadsUtil.removeById(context, info.id); return; } Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE); installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); installIntent.setDataAndType(Uri.fromFile(localFile), DownloadsUtil.MIME_TYPE_APK); // installIntent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true); // installIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true); installIntent.putExtra( Intent.EXTRA_INSTALLER_PACKAGE_NAME, context.getApplicationInfo().packageName); context.startActivity(installIntent); }
public static ActivityInfo[] getActivityList(Context context, String packageName) throws NameNotFoundException { PackageManager pm = context.getPackageManager(); PackageInfo info = pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); ActivityInfo[] list = info.activities; return list; }
/** * 指定のIntentがNotActivityFoundExceptionにならずに使えるか調べる<br> * 処理できるアプリが存在しない場合指定のアプリをダウンロードさせる * * @param context * @param intent 処理できるか調べたいIntent * @param appName 処理できなかったときダウンロードさせるアプリの名前 * @param packageName 処理できなかったときダウンロードさせるアプリのpackage名 * @return 処理できるならtrue, 処理できないならfalse */ public static boolean canResolveActivity( Context context, Intent intent, String appName, String packageName) { sContext = context; ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, 0); // 対応できるAppがインストールされていればそのまま処理 if (resolveInfo != null) { return true; } // なければ、Marketに取得しにいくか聞く。 sPackageName = packageName; AlertDialog.Builder diagBldr = new AlertDialog.Builder(context); diagBldr.setTitle(context.getString(R.string.cant_resolve_intent_title, appName)); diagBldr.setMessage(context.getString(R.string.cant_resolve_intent_message)); diagBldr.setPositiveButton(context.getString(R.string.go_market), sOnClick); diagBldr.setNegativeButton(context.getString(R.string.ignore), sOnClick); diagBldr.setCancelable(true); diagBldr.create(); diagBldr.show(); return false; }
/** * Adds two query parameters into the Uri, namely the language code and the version code of the * app's package as gotten via the context. * * @return the uri with added query parameters */ private static Uri uriWithAddedParameters(Context context, Uri baseUri) { Uri.Builder builder = baseUri.buildUpon(); // Add in the preferred language builder.appendQueryParameter(PARAM_LANGUAGE_CODE, Locale.getDefault().toString()); // Add in the package version code if (sCachedVersionCode == null) { // There is no cached version code, so try to get it from the package manager. try { // cache the version code PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); sCachedVersionCode = Integer.toString(info.versionCode); // append the version code to the uri builder.appendQueryParameter(PARAM_VERSION, sCachedVersionCode); } catch (NameNotFoundException e) { // Cannot find the package name, so don't add in the version parameter // This shouldn't happen. Log.wtf("Invalid package name for context " + e); } } else { builder.appendQueryParameter(PARAM_VERSION, sCachedVersionCode); } // Build the full uri and return it return builder.build(); }
@Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { boolean isCheckin = false; if (args != null) { for (String arg : args) { if ("--checkin".equals(arg)) { isCheckin = true; } else if ("--reset".equals(arg)) { synchronized (mStats) { mStats.resetAllStatsLocked(); pw.println("Battery stats reset."); } } } } if (isCheckin) { List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(0); synchronized (mStats) { mStats.dumpCheckinLocked(pw, args, apps); } } else { synchronized (mStats) { mStats.dumpLocked(pw); } } }
/** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link Context} to use for creating the cache dir. * @param stack An {@link HttpStack} to use for the network, or null for default. * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context, HttpStack stack) { File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR); String userAgent = "volley/0"; try { String packageName = context.getPackageName(); PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0); userAgent = packageName + "/" + info.versionCode; } catch (NameNotFoundException e) { } if (stack == null) { if (Build.VERSION.SDK_INT >= 9) { stack = new HurlStack(); } else { // Prior to Gingerbread, HttpUrlConnection was unreliable. // See: http://android-developers.blogspot.com/2011/09/androids-http-clients.html stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent)); } } Network network = new BasicNetwork(stack); RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network); queue.start(); return queue; }
private LocalRepoManager(Context c) { context = c.getApplicationContext(); pm = c.getPackageManager(); assetManager = c.getAssets(); fdroidPackageName = c.getPackageName(); webRoot = SanitizedFile.knownSanitized(c.getFilesDir()); /* /fdroid/repo is the standard path for user repos */ fdroidDir = new SanitizedFile(webRoot, "fdroid"); fdroidDirCaps = new SanitizedFile(webRoot, "FDROID"); repoDir = new SanitizedFile(fdroidDir, "repo"); repoDirCaps = new SanitizedFile(fdroidDirCaps, "REPO"); iconsDir = new SanitizedFile(repoDir, "icons"); xmlIndex = new SanitizedFile(repoDir, "index.xml"); xmlIndexJar = new SanitizedFile(repoDir, "index.jar"); xmlIndexJarUnsigned = new SanitizedFile(repoDir, "index.unsigned.jar"); if (!fdroidDir.exists()) if (!fdroidDir.mkdir()) Log.e(TAG, "Unable to create empty base: " + fdroidDir); if (!repoDir.exists()) if (!repoDir.mkdir()) Log.e(TAG, "Unable to create empty repo: " + repoDir); if (!iconsDir.exists()) if (!iconsDir.mkdir()) Log.e(TAG, "Unable to create icons folder: " + iconsDir); }
static String getVersion(Context c) { try { return c.getPackageManager().getPackageInfo(c.getPackageName(), 0).versionName; } catch (Exception e) { return c.getString(R.string.unknown_version); } }
/** * Create a notification as the visible part to be able to put the service in a foreground state. * * @return A local ongoing notification which pending intent is bound to the main activity. */ @SuppressLint("NewApi") @SuppressWarnings("deprecation") private Notification makeNotification() { JSONObject settings = BackgroundMode.getSettings(); Context context = getApplicationContext(); String pkgName = context.getPackageName(); Intent intent = context.getPackageManager().getLaunchIntentForPackage(pkgName); Notification.Builder notification = new Notification.Builder(context) .setContentTitle(settings.optString("title", "Title")) .setContentText(settings.optString("text", "Content")) .setTicker(settings.optString("ticker", "Ticker")) .setOngoing(true) .setSmallIcon(getIconResId()); if (intent != null && settings.optBoolean("resume")) { PendingIntent contentIntent = PendingIntent.getActivity( context, NOTIFICATION_ID, intent, PendingIntent.FLAG_CANCEL_CURRENT); notification.setContentIntent(contentIntent); } if (Build.VERSION.SDK_INT < 16) { // Build notification for HoneyComb to ICS return notification.getNotification(); } else { // Notification for Jellybean and above return notification.build(); } }