List of usage examples for android.content Intent CATEGORY_LAUNCHER
String CATEGORY_LAUNCHER
To view the source code for android.content Intent CATEGORY_LAUNCHER.
Click Source Link
From source file:ti.modules.titanium.audio.streamer.NotificationHelper.java
/** * Open to the now playing screen/* w ww. j a v a2s . c o m*/ */ private PendingIntent getPendingIntent() { TiApplication app = TiApplication.getInstance(); Intent i = app.getPackageManager().getLaunchIntentForPackage(app.getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); i.addCategory(Intent.CATEGORY_LAUNCHER); i.setAction(Intent.ACTION_MAIN); PendingIntent pendingIntent = PendingIntent.getActivity(app, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); return pendingIntent; }
From source file:net.iamyellow.gcmjs.GcmjsModule.java
/** * Create big style notification//from w ww . j av a 2 s. c o m * @param ntfId : counter for number of unread notification * @param title : notification title * @param message : notification body message * @param tickerText : notification text that appears on notification area when closed * @param icon : icon that will appear beside the notification * @param notificationId : unique notification id */ @Kroll.method public void createBigNotificationStyle(int ntfId, String title, String message, String tickerText, int icon, int notificationId) { Intent intent = new Intent(); intent.setAction("action" + ntfId); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setClassName(TiApplication.getInstance().getApplicationContext().getPackageName(), TiApplication.getInstance().getPackageManager() .getLaunchIntentForPackage(TiApplication.getInstance().getPackageName()).getComponent() .getClassName()); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.putExtra("ntfId", ntfId); PendingIntent pintent = PendingIntent.getActivity(TiApplication.getInstance().getApplicationContext(), 0, intent, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder( TiApplication.getInstance().getApplicationContext()).setContentIntent(pintent).setSmallIcon(icon) .setContentTitle(title).setContentText(message).setTicker(tickerText).setAutoCancel(true) .setNumber(ntfId) // .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE // permission /* * Sets the big view "big text" style and supplies the text (the * user's reminder message) that will be displayed in the detail * area of the expanded notification. These calls are ignored by * the support library for pre-4.1 devices. */ .setStyle(new NotificationCompat.BigTextStyle().bigText(message)); NotificationManager mNotificationManager = (NotificationManager) TiApplication.getInstance() .getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); // notificationId allows you to update the notification later on. mNotificationManager.notify(notificationId, builder.build()); }
From source file:org.wso2.app.catalog.api.ApplicationManager.java
/** * Checks whether the DownloadManager is available on the device. * * @param context - Context of the calling activity. *//*from w w w.j ava 2 s . c o m*/ public boolean isDownloadManagerAvailable(Context context) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setClassName(resources.getString(R.string.android_download_manager_ui_resolver), resources.getString(R.string.android_download_manager_list_resolver)); return context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY) .size() > 0; }
From source file:com.pdmanager.views.caregiver.CaregiverActivity.java
@Override public void onMessageReceived(final CNMessage cnMessage) { if (application.getUniqueId().equals(cnMessage.getUniqueId())) { return;/*from w w w. java2 s .c om*/ } if (cnMessage.getMessageType() == CNMessage.CNMessageType.Calling) { if (application.isInConference()) { application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.Busy, null); return; } callDialog = new AlertDialog.Builder(this).create(); LayoutInflater inflater = getLayoutInflater(); View incomingCallDialog = inflater.inflate(R.layout.incoming_call_dialog, null); incomingCallDialog.setAlpha(0.5f); callDialog.setView(incomingCallDialog); TextView caller = (TextView) incomingCallDialog.findViewById(R.id.caller); caller.setText(cnMessage.getDisplayName()); Button answerButton = (Button) incomingCallDialog.findViewById(R.id.answer_button); answerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { application.setConferenceId(cnMessage.getConferenceId()); application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.AnswerAccept, null); callDialog.hide(); currentRingtone.stop(); Intent intent = new Intent(application.getContext(), CaregiverActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(intent); application.join(application.getConferenceId(), true); } }); Button declineButton = (Button) incomingCallDialog.findViewById(R.id.decline_button); declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { application.sendCNMessage(cnMessage.getFrom(), CNMessage.CNMessageType.AnswerDecline, null); currentRingtone.stop(); callDialog.hide(); } }); callDialog.setCancelable(false); callDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); //play current Ringtone currentRingtone.play(); callDialog.show(); } else if (cnMessage.getMessageType() == CNMessage.CNMessageType.Cancel) { currentRingtone.stop(); callDialog.hide(); } else if (cnMessage.getMessageType() == CNMessage.CNMessageType.EndCall) { if (application.leave()) { int count = getFragmentManager().getBackStackEntryCount(); String name = getFragmentManager().getBackStackEntryAt(count - 2).getName(); getFragmentManager().popBackStack(name, FragmentManager.POP_BACK_STACK_INCLUSIVE); } } }
From source file:support.plus.reportit.MainActivity.java
private void shareAppLinkViaFacebook(String content) { try {/* w w w . j a v a2 s.co m*/ Intent intent1 = new Intent(); intent1.setClassName("com.facebook.katana", "com.facebook.katana.activity.composer.ImplicitShareIntentHandler"); intent1.setAction("android.intent.action.SEND"); intent1.setType("text/plain"); intent1.putExtra(Intent.EXTRA_TEXT, content); intent1.addCategory(Intent.CATEGORY_LAUNCHER); intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); startActivity(intent1); } catch (Exception e) { // If we failed (no native FB app installed), try share through SEND Intent intent = new Intent(Intent.ACTION_SEND); String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + content; intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl)); startActivity(intent); } }
From source file:com.vyasware.vaani.MainActivity.java
private void doOpen(String[] sentence) { System.out.println("open"); for (String word : sentence) { switch (word) { //? ??? case "?": case "facebook": //open facebook Intent fbintent = new Intent(); fbintent.setAction(Intent.ACTION_VIEW); fbintent.setData(android.net.Uri.parse("http://www.facebook.com")); startActivity(fbintent);/*from w ww. j a v a 2 s.c om*/ break; case "whatsapp": case "???": //todo run whatsapp break; case "camera": case "": case "": //open camera Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); try { PackageManager pm = getPackageManager(); final ResolveInfo mInfo = pm.resolveActivity(i, 0); Intent intent = new Intent(); intent.setComponent(new ComponentName(mInfo.activityInfo.packageName, mInfo.activityInfo.name)); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(intent); } catch (Exception e) { Log.i("open", "Unable to launch camera: " + e); } break; case "browser": case "?": // open browser Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(android.net.Uri.parse("http://www.google.com")); startActivity(intent); break; case "youtube": case "???": //run youtube Intent ytintent = new Intent(); ytintent.setAction(Intent.ACTION_VIEW); ytintent.setData(android.net.Uri.parse("http://www.youtube.com")); startActivity(ytintent); break; } } }
From source file:com.andernity.launcher2.InstallShortcutReceiver.java
private static boolean installShortcut(Context context, Intent data, ArrayList<ItemInfo> items, String name, final Intent intent, final int screen, boolean shortcutExists, final SharedPreferences sharedPrefs, int[] result) { int[] tmpCoordinates = new int[2]; if (findEmptyCell(context, items, tmpCoordinates, screen)) { if (intent != null) { if (intent.getAction() == null) { intent.setAction(Intent.ACTION_VIEW); } else if (intent.getAction().equals(Intent.ACTION_MAIN) && intent.getCategories() != null && intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); }//from w w w . j a va 2 s . c o m // By default, we allow for duplicate entries (located in // different places) boolean duplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true); if (duplicate || !shortcutExists) { new Thread("setNewAppsThread") { public void run() { synchronized (sLock) { // If the new app is going to fall into the same page as before, // then just continue adding to the current page final int newAppsScreen = sharedPrefs.getInt(NEW_APPS_PAGE_KEY, screen); SharedPreferences.Editor editor = sharedPrefs.edit(); if (newAppsScreen == -1 || newAppsScreen == screen) { addToStringSet(sharedPrefs, editor, NEW_APPS_LIST_KEY, intent.toUri(0)); } editor.putInt(NEW_APPS_PAGE_KEY, screen); editor.commit(); } } }.start(); // Update the Launcher db LauncherApplication app = (LauncherApplication) context.getApplicationContext(); ShortcutInfo info = app.getModel().addShortcut(context, data, LauncherSettings.Favorites.CONTAINER_DESKTOP, screen, tmpCoordinates[0], tmpCoordinates[1], true); if (info == null) { return false; } } else { result[0] = INSTALL_SHORTCUT_IS_DUPLICATE; } return true; } } else { result[0] = INSTALL_SHORTCUT_NO_SPACE; } return false; }
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:org.onepf.oms.appstore.SamsungAppsBillingService.java
@Override public void launchPurchaseFlow(Activity activity, String sku, String itemType, int requestCode, OnIabPurchaseFinishedListener listener, String extraData) { String itemGroupId = getItemGroupId(sku); String itemId = getItemId(sku); Bundle bundle = new Bundle(); bundle.putString(KEY_NAME_THIRD_PARTY_NAME, activity.getPackageName()); bundle.putString(KEY_NAME_ITEM_GROUP_ID, itemGroupId); bundle.putString(KEY_NAME_ITEM_ID, itemId); if (isDebugLog()) Log.d(TAG, "launchPurchase: itemGroupId = " + itemGroupId + ", itemId = " + itemId); ComponentName cmpName = new ComponentName(SamsungApps.IAP_PACKAGE_NAME, PAYMENT_ACTIVITY_NAME); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(cmpName);/*from w ww .j av a 2 s . c o m*/ intent.putExtras(bundle); mRequestCode = requestCode; mPurchaseListener = listener; purchasingItemType = itemType; mItemGroupId = itemGroupId; mExtraData = extraData; if (isDebugLog()) Log.d(TAG, "Request code: " + requestCode); activity.startActivityForResult(intent, requestCode); }
From source file:com.rainmakerlabs.bleepsample.BleepService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "onStartCommand"); String actionName = intent.getStringExtra("actionName"); if (intent == null || intent.getExtras() == null) {//just removing these checks } else if (actionName.equalsIgnoreCase(BLEepService.INTENT_BLEEP_PROCESS) && intent.getExtras().containsKey(BLEepService.INTENT_BLEEP_PASSED_LIST)) { ArrayList<Bleep> bleeps = (ArrayList<Bleep>) intent.getExtras() .getSerializable(BLEepService.INTENT_BLEEP_PASSED_LIST); for (final Bleep bleep : bleeps) { String msgType = bleep.getType(); String atts = bleep.getAtts(); try { JSONObject objMsg = new JSONObject(atts); //thisBleepService.addExtraLog(bleep, "FEEDBACK", "good");//use this when you want to send a custom log to BMS. for instance, you could display a feedback dialog, and ask users to give a rating, and BMS will help you collate the information. put this where necessary, it's just here for example Log.d(TAG, "Message Received of Type: " + msgType); if (msgType.equalsIgnoreCase("image")) { final String strImgUrl = objMsg.optString(APIKeyDefineCommand.MSG_IMG); final String adAspect = objMsg.optString(APIKeyDefineCommand.MSG_IMGASP); String strImgMsgTemp = objMsg.optString(APIKeyDefineCommand.MSG_NOTIF); //putting the default message above would only work for missing key, not in case of empty string. empty string will prevent the notification, so fix below if (strImgMsgTemp.equalsIgnoreCase("")) strImgMsgTemp = "No Message"; final String strImgMsg = strImgMsgTemp; if (checkIfClosed()) { if (oldcodeon) localNotification("", strImgMsg, 0); continue; }//from ww w . j a v a 2 s. c om if (MainActivity.adlib.get(strImgMsg) == null && !strImgMsg.equalsIgnoreCase("No Message")) Log.d(TAG, "image url start download for key: " + strImgMsg + ", url = " + strImgUrl); else { Log.d(TAG, "Image exists, or no message, not downloading..., key: " + strImgMsg); continue; } if (strImgMsg.equalsIgnoreCase("$28")) { Log.d("Portal", "Image exists, loading from cache"); imgShow(BitmapFactory.decodeResource(getResources(), R.drawable.singtel), strImgMsg); continue; } else if (strImgMsg.equalsIgnoreCase("$4.50")) { Log.d("Portal", "Heineken Image exists, loading from cache"); imgShow(BitmapFactory.decodeResource(getResources(), R.drawable.heineken), strImgMsg); continue; } ShutterbugManager.getSharedImageManager(BleepActivity.currentBleepActivity) .download(strImgUrl, new ShutterbugManagerListener() { @Override public void onImageSuccess(ShutterbugManager imageManager, Bitmap bitmap, String url) { Log.d(TAG, "image url end download " + strImgUrl); if (strImgUrl.equalsIgnoreCase(AdDialog.getCurrentAdUrl())) return; if (AdDialog.howManyAdDialogsShowing == 1) { AdDialog.closeOnlyAdDialog(); } final Bitmap bitmap2 = bitmap; imgShow(bitmap, strImgMsg); if (oldcodeon) { BleepActivity.currentBleepActivity.runOnUiThread(new Runnable() { public void run() { if (BleepActivity.isBackground) localNotification("", strImgMsg, 0); AdDialog.showAdsDialog(BleepActivity.currentBleepActivity, bitmap2, strImgUrl, adAspect); } }); } } @Override public void onImageFailure(ShutterbugManager imageManager, String url) { thisBleepService.eraseTriggerLog(bleep);//to cancel trigger log when trigger is cancelled } }); } else if (oldcodeon == false) {//don't run anything else } else if (msgType.equalsIgnoreCase("alert") && oldcodeon) { // show alert message if (checkIfClosed() || BleepActivity.isBackground) { localNotification(objMsg.optString(APIKeyDefineCommand.MSG_TITLE), objMsg.optString(APIKeyDefineCommand.MSG_CONTENT), 1); } else { showAlert(objMsg.optString(APIKeyDefineCommand.MSG_TITLE), objMsg.optString(APIKeyDefineCommand.MSG_CONTENT)); } } else if (msgType.equalsIgnoreCase("launch")) { String intentAction = objMsg.optString(APIKeyDefineCommand.MSG_APP_INTENT); String intentUri = objMsg.optString(APIKeyDefineCommand.MSG_APP_URI); String intentType = ""; String intentExtras = objMsg.optString(APIKeyDefineCommand.MSG_APP_EXTRAS); String cfmMsg = objMsg.optString(APIKeyDefineCommand.MSG_APP_CFM); String failMsg = objMsg.optString(APIKeyDefineCommand.MSG_APP_FAIL); processTypeLaunch(intentAction, intentUri, intentType, intentExtras, cfmMsg, failMsg, 2); } else if (msgType.equalsIgnoreCase("url")) { String intentAction = Intent.ACTION_VIEW; String intentUri = objMsg.optString(APIKeyDefineCommand.MSG_MEDIA_URL); String intentType = ""; String intentExtras = ""; String cfmMsg = objMsg.optString(APIKeyDefineCommand.MSG_APP_CFM); String failMsg = objMsg.optString(APIKeyDefineCommand.MSG_APP_FAIL); processTypeLaunch(intentAction, intentUri, intentType, intentExtras, cfmMsg, failMsg, 3); } else if (msgType.equalsIgnoreCase("webview")) { String intentAction = Intent.ACTION_VIEW; String intentUri = objMsg.optString(APIKeyDefineCommand.MSG_MEDIA_URL); String intentType = ""; String intentExtras = ""; String cfmMsg = objMsg.optString(APIKeyDefineCommand.MSG_NOTIF); if (cfmMsg.equalsIgnoreCase("")) cfmMsg = "View webpage?"; String failMsg = ""; processTypeLaunch(intentAction, intentUri, intentType, intentExtras, cfmMsg, failMsg, 4); } else if (msgType.equalsIgnoreCase("video")) { String strVidUrl = objMsg.optString(APIKeyDefineCommand.MSG_MEDIA_URL); Intent vidIntent = new Intent(this, VideoActivity.class); vidIntent.putExtra("url", strVidUrl); String notifMsg = objMsg.optString(APIKeyDefineCommand.MSG_NOTIF); if (notifMsg.equalsIgnoreCase("")) notifMsg = "Play video?"; if (!checkIfClosed() && BleepActivity.isVideoActivityOpen) { thisBleepService.eraseTriggerLog(bleep);//to cancel trigger log when trigger is cancelled } else if (checkIfClosed() || BleepActivity.isBackground) { vidIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); vidIntent.setAction(Intent.ACTION_MAIN); vidIntent.addCategory(Intent.CATEGORY_LAUNCHER); localNotification("", notifMsg, vidIntent, "Video opening failed!", 5); } else { BleepActivity.currentBleepActivity.startActivity(vidIntent); } } else if (msgType.equalsIgnoreCase("audio")) { String url = objMsg.optString(APIKeyDefineCommand.MSG_MEDIA_URL); mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mediaPlayer.setDataSource(url); } catch (IOException e) { e.printStackTrace(); } mediaPlayer.prepareAsync(); mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.start(); } }); mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { return false; } }); } } catch (JSONException e) { e.printStackTrace(); } } // } else if (actionName.equalsIgnoreCase(BLEepService.INTENT_BLEEP_EXIT) && intent.getExtras().containsKey(BLEepService.INTENT_MSG_NAME)) { // HashMap<String, Object> beaconOutInfo = (HashMap<String, Object>)intent.getSerializableExtra(BLEepService.INTENT_MSG_NAME); // //Log.d("debug!","debug! this beacon just went out "+beaconOutInfo.get("uuid")+" "+beaconOutInfo.get("major")+" "+beaconOutInfo.get("minor")+" "+beaconOutInfo.get("tag")+" "+beaconOutInfo.get("beaconID")); } else if (actionName.equalsIgnoreCase(BLEepService.INTENT_BLEEP_STATE) && intent.getExtras().containsKey(BLEepService.INTENT_MSG_NAME)) { int beaconState = intent.getIntExtra(BLEepService.INTENT_MSG_NAME, 99); } return START_NOT_STICKY; }