Example usage for android.content Intent setFlags

List of usage examples for android.content Intent setFlags

Introduction

In this page you can find the example usage for android.content Intent setFlags.

Prototype

public @NonNull Intent setFlags(@Flags int flags) 

Source Link

Document

Set special flags controlling how this intent is handled.

Usage

From source file:com.netpace.expressit.activity.UploadVideoStoryActivity.java

private void publishMediaOnRemoteServer() {

    dialog.setMessage("Publishing on XIT...");

    Media media = new Media();
    media.setMediaShortURL(fileKey);/*from w  w  w .j a  v a2  s  . c  o  m*/
    media.setMediaName(fileKey + "." + FileUtils.getFileExtension(video_filePath));
    media.setMediaCaption(titleTextView.getText().toString());
    media.setMediaType(MediaTypeEnum.VIDEO);

    Meta meta = new Meta();
    meta.setThumb(fileKey + "-thumb." + FileUtils.getFileExtension(thumb_filePath));
    media.setMeta(meta);

    ADMediaSharingUtil.getRestClient(UploadVideoStoryActivity.this)
            .load(AppConstants.DOMAIN_URL + AppConstants.PUBLISH_MEDIA_URL).setJsonObjectBody(media).asString()
            .withResponse().setCallback(new FutureCallback<Response<String>>() {

                @Override
                public void onCompleted(Exception e, Response<String> result) {
                    if (dialog.isShowing())
                        dialog.dismiss();
                    if (e == null && result.getHeaders().getResponseCode() == HttpStatus.SC_OK) {
                        Toast.makeText(UploadVideoStoryActivity.this, "Uploaded Successfully",
                                Toast.LENGTH_SHORT).show();
                        Intent intent = new Intent(UploadVideoStoryActivity.this, SlideMenuActivity.class);
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        startActivity(intent);
                    } else {
                        Toast.makeText(UploadVideoStoryActivity.this, e.getLocalizedMessage(),
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}

From source file:br.com.arlsoft.pushclient.PushClientModule.java

public static void sendNotification(Bundle extras) {
    if (extras == null || extras.isEmpty())
        return;//from w  w w .java2s. c o m

    TiApplication appContext = TiApplication.getInstance();
    int appIconId = appContext.getResources().getIdentifier("appicon", "drawable", appContext.getPackageName());
    String appName = appContext.getAppInfo().getName();

    Bundle extrasRoot = extras;

    int badgeCount = -1;
    int notificationId = 0;
    String notificationTitle = null;
    String notificationText = null;
    String notificationTicker = null;
    Uri notificationSound = null;
    int notificationDefaults = 0;

    // TEXT
    if (extras.containsKey("text")) {
        notificationText = extras.getString("text");
    } else if (extras.containsKey("alert")) {
        notificationText = extras.getString("alert");
    } else if (extras.containsKey("message")) {
        notificationText = extras.getString("message");
    } else if (extras.containsKey("data")) {
        try {
            JSONObject reader = new JSONObject(extras.getString("data"));
            Bundle newExtras = new Bundle();
            for (int i = 0; i < reader.names().length(); i++) {
                String key = reader.names().getString(i);
                newExtras.putString(key, reader.getString(key));
            }
            if (newExtras.containsKey("text")) {
                notificationText = newExtras.getString("text");
                extras = newExtras;
            } else if (newExtras.containsKey("alert")) {
                notificationText = newExtras.getString("alert");
                extras = newExtras;
            } else if (newExtras.containsKey("message")) {
                notificationText = newExtras.getString("message");
                extras = newExtras;
            }
        } catch (JSONException e) {
            String text = extras.getString("data");
            if (text != null) {
                notificationText = text;
            }
        }
    } else if (extras.containsKey("msg")) {
        try {
            JSONObject reader = new JSONObject(extras.getString("msg"));
            Bundle newExtras = new Bundle();
            for (int i = 0; i < reader.names().length(); i++) {
                String key = reader.names().getString(i);
                newExtras.putString(key, reader.getString(key));
            }
            if (newExtras.containsKey("text")) {
                notificationText = newExtras.getString("text");
                extras = newExtras;
            } else if (newExtras.containsKey("alert")) {
                notificationText = newExtras.getString("alert");
                extras = newExtras;
            } else if (newExtras.containsKey("message")) {
                notificationText = newExtras.getString("message");
                extras = newExtras;
            }
        } catch (JSONException e) {
            String text = extras.getString("msg");
            if (text != null) {
                notificationText = text;
            }
        }
    } else if (extras.containsKey("default")) {
        try {
            JSONObject reader = new JSONObject(extras.getString("default"));
            Bundle newExtras = new Bundle();
            for (int i = 0; i < reader.names().length(); i++) {
                String key = reader.names().getString(i);
                newExtras.putString(key, reader.getString(key));
            }
            if (newExtras.containsKey("text")) {
                notificationText = newExtras.getString("text");
                extras = newExtras;
            } else if (newExtras.containsKey("alert")) {
                notificationText = newExtras.getString("alert");
                extras = newExtras;
            } else if (newExtras.containsKey("message")) {
                notificationText = newExtras.getString("message");
                extras = newExtras;
            }
        } catch (JSONException e) {
            String text = extras.getString("default");
            if (text != null) {
                notificationText = text;
            }
        }
    } else if (extras.containsKey("payload")) {
        try {
            JSONObject reader = new JSONObject(extras.getString("payload"));
            Bundle newExtras = new Bundle();
            for (int i = 0; i < reader.names().length(); i++) {
                String key = reader.names().getString(i);
                newExtras.putString(key, reader.getString(key));
            }
            if (newExtras.containsKey("text")) {
                notificationText = newExtras.getString("text");
                extras = newExtras;
            } else if (newExtras.containsKey("alert")) {
                notificationText = newExtras.getString("alert");
                extras = newExtras;
            } else if (newExtras.containsKey("message")) {
                notificationText = newExtras.getString("message");
                extras = newExtras;
            }
        } catch (JSONException e) {
            String text = extras.getString("payload");
            if (text != null) {
                notificationText = text;
            }
        }
    }

    // TITLE
    if (extras.containsKey("title")) {
        notificationTitle = extras.getString("title");
    } else {
        notificationTitle = appName;
    }

    // TICKER
    if (extras.containsKey("ticker")) {
        notificationTicker = extras.getString("ticker");
    } else {
        notificationTicker = notificationText;
    }

    // SOUND
    if (extras.containsKey("sound")) {
        if (extras.getString("sound").equalsIgnoreCase("default")) {
            notificationDefaults |= Notification.DEFAULT_SOUND;
        } else {
            File file = null;
            // getResourcesDirectory
            file = new File("app://" + extras.getString("sound"));
            if (file != null && file.exists()) {
                notificationSound = Uri.fromFile(file);
            } else {
                // getResourcesDirectory + sound folder
                file = new File("app://sound/" + extras.getString("sound"));
                if (file != null && file.exists()) {
                    notificationSound = Uri.fromFile(file);
                } else {
                    // getExternalStorageDirectory
                    file = new File("appdata://" + extras.getString("sound"));
                    if (file != null && file.exists()) {
                        notificationSound = Uri.fromFile(file);
                    } else {
                        // getExternalStorageDirectory + sound folder
                        file = new File("appdata://sound/" + extras.getString("sound"));
                        if (file != null && file.exists()) {
                            notificationSound = Uri.fromFile(file);
                        } else {
                            // res folder
                            int soundId = appContext.getResources().getIdentifier(extras.getString("sound"),
                                    "raw", appContext.getPackageName());
                            if (soundId != 0) {
                                notificationSound = Uri.parse("android.resource://"
                                        + appContext.getPackageName() + "/raw/" + soundId);
                            } else {
                                // res folder without file extension
                                String soundFile = extras.getString("sound").split("\\.")[0];
                                soundId = appContext.getResources().getIdentifier(soundFile, "raw",
                                        appContext.getPackageName());
                                if (soundId != 0) {
                                    notificationSound = Uri.parse("android.resource://"
                                            + appContext.getPackageName() + "/raw/" + soundId);
                                }
                            }
                        }
                    }
                }
            }
        }
    } else if (extrasRoot.containsKey("sound")) {
        if (extrasRoot.getString("sound").equalsIgnoreCase("default")) {
            notificationDefaults |= Notification.DEFAULT_SOUND;
        } else {
            File file = null;
            // getResourcesDirectory
            file = new File("app://" + extrasRoot.getString("sound"));
            if (file != null && file.exists()) {
                notificationSound = Uri.fromFile(file);
            } else {
                // getResourcesDirectory + sound folder
                file = new File("app://sound/" + extrasRoot.getString("sound"));
                if (file != null && file.exists()) {
                    notificationSound = Uri.fromFile(file);
                } else {
                    // getExternalStorageDirectory
                    file = new File("appdata://" + extrasRoot.getString("sound"));
                    if (file != null && file.exists()) {
                        notificationSound = Uri.fromFile(file);
                    } else {
                        // getExternalStorageDirectory + sound folder
                        file = new File("appdata://sound/" + extrasRoot.getString("sound"));
                        if (file != null && file.exists()) {
                            notificationSound = Uri.fromFile(file);
                        } else {
                            // res folder
                            int soundId = appContext.getResources().getIdentifier(extrasRoot.getString("sound"),
                                    "raw", appContext.getPackageName());
                            if (soundId != 0) {
                                notificationSound = Uri.parse("android.resource://"
                                        + appContext.getPackageName() + "/raw/" + soundId);
                            } else {
                                // res folder without file extension
                                String soundFile = extrasRoot.getString("sound").split("\\.")[0];
                                soundId = appContext.getResources().getIdentifier(soundFile, "raw",
                                        appContext.getPackageName());
                                if (soundId != 0) {
                                    notificationSound = Uri.parse("android.resource://"
                                            + appContext.getPackageName() + "/raw/" + soundId);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    // VIBRATE
    if (extras.containsKey("vibrate") && extras.getString("vibrate").equalsIgnoreCase("true")) {
        notificationDefaults |= Notification.DEFAULT_VIBRATE;
    }

    // LIGHTS
    if (extras.containsKey("lights") && extras.getString("lights").equalsIgnoreCase("true")) {
        notificationDefaults |= Notification.DEFAULT_LIGHTS;
    }

    // NOTIFICATION ID
    if (extras.containsKey("notificationId")) {
        try {
            notificationId = Integer.parseInt(extras.getString("notificationId"));
        } catch (NumberFormatException nfe) {
        }
    }
    if (notificationId == 0) {
        notificationId = appContext.getAppProperties().getInt(PROPERTY_NOTIFICATION_ID, 0);
        notificationId++;
        appContext.getAppProperties().setInt(PROPERTY_NOTIFICATION_ID, notificationId);
    }

    // BADGE
    if (extras.containsKey("badge")) {
        try {
            badgeCount = Integer.parseInt(extras.getString("badge"));
        } catch (NumberFormatException nfe) {
        }
    }

    // LARGE ICON
    Bitmap largeIcon = null;
    if (extras.containsKey("largeIcon")) {
        largeIcon = getBitmap(extras.getString("largeIcon"));
    } else if (extras.containsKey("licon")) {
        largeIcon = getBitmap(extras.getString("licon"));
    } else if (extrasRoot.containsKey("largeIcon")) {
        largeIcon = getBitmap(extrasRoot.getString("largeIcon"));
    } else if (extrasRoot.containsKey("licon")) {
        largeIcon = getBitmap(extrasRoot.getString("licon"));
    }

    // SMALL ICON
    if (extras.containsKey("smallIcon")) {
        appIconId = appContext.getResources().getIdentifier(extras.getString("smallIcon"), "drawable",
                appContext.getPackageName());
        if (appIconId == 0) {
            Log.i(TAG, "Unable to find resource identifier to custom smallIcon : "
                    + extras.getString("smallIcon"));
        }
    } else if (extras.containsKey("sicon")) {
        appIconId = appContext.getResources().getIdentifier(extras.getString("sicon"), "drawable",
                appContext.getPackageName());
        if (appIconId == 0) {
            Log.i(TAG, "Unable to find resource identifier to custom sicon : " + extras.getString("sicon"));
        }
    } else if (extrasRoot.containsKey("smallIcon")) {
        appIconId = appContext.getResources().getIdentifier(extrasRoot.getString("smallIcon"), "drawable",
                appContext.getPackageName());
        if (appIconId == 0) {
            Log.i(TAG, "Unable to find resource identifier to custom smallIcon : "
                    + extrasRoot.getString("smallIcon"));
        }
    } else if (extrasRoot.containsKey("sicon")) {
        appIconId = appContext.getResources().getIdentifier(extrasRoot.getString("sicon"), "drawable",
                appContext.getPackageName());
        if (appIconId == 0) {
            Log.i(TAG, "Unable to find resource identifier to custom smallIcon : "
                    + extrasRoot.getString("sicon"));
        }
    }

    if (notificationText != null) {
        // Intent launch = getLauncherIntent(extras);
        Intent launch = new Intent(appContext, PendingNotificationActivity.class);
        launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (extrasRoot != null && !extrasRoot.isEmpty()) {
            launch.putExtra(PROPERTY_EXTRAS, extrasRoot);
        }
        launch.setAction("dummy_unique_action_identifyer:" + notificationId);

        PendingIntent contentIntent = PendingIntent.getActivity(appContext, 0, launch,
                PendingIntent.FLAG_CANCEL_CURRENT);
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(appContext);

        mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationText));
        mBuilder.setContentText(notificationText);

        if (notificationTitle != null) {
            mBuilder.setContentTitle(notificationTitle);
        }
        if (notificationTicker != null) {
            mBuilder.setTicker(notificationTicker);
        }
        if (notificationDefaults != 0) {
            mBuilder.setDefaults(notificationDefaults);
        }
        if (notificationSound != null) {
            mBuilder.setSound(notificationSound);
        }
        if (badgeCount >= 0) {
            mBuilder.setNumber(badgeCount);
        }
        if (largeIcon != null) {
            mBuilder.setLargeIcon(largeIcon);
        }

        if (appIconId == 0) {
            appIconId = appContext.getResources().getIdentifier("appicon", "drawable",
                    appContext.getPackageName());
        }

        mBuilder.setSmallIcon(appIconId);
        mBuilder.setContentIntent(contentIntent);
        mBuilder.setAutoCancel(true);
        mBuilder.setWhen(System.currentTimeMillis());

        // ledARGB, ledOnMS, ledOffMS
        boolean customLight = false;
        int argb = 0xFFFFFFFF;
        int onMs = 1000;
        int offMs = 2000;
        if (extras.containsKey("ledARGB")) {
            try {
                argb = TiColorHelper.parseColor(extras.getString("ledARGB"));
                customLight = true;
            } catch (Exception ex) {
                try {
                    argb = Integer.parseInt(extras.getString("ledARGB"));
                    customLight = true;
                } catch (NumberFormatException nfe) {
                }
            }
        } else if (extras.containsKey("ledc")) {
            try {
                argb = TiColorHelper.parseColor(extras.getString("ledc"));
                customLight = true;
            } catch (Exception ex) {
                try {
                    argb = Integer.parseInt(extras.getString("ledc"));
                    customLight = true;
                } catch (NumberFormatException nfe) {
                }
            }
        } else if (extrasRoot.containsKey("ledARGB")) {
            try {
                argb = TiColorHelper.parseColor(extrasRoot.getString("ledARGB"));
                customLight = true;
            } catch (Exception ex) {
                try {
                    argb = Integer.parseInt(extrasRoot.getString("ledARGB"));
                    customLight = true;
                } catch (NumberFormatException nfe) {
                }
            }
        } else if (extrasRoot.containsKey("ledc")) {
            try {
                argb = TiColorHelper.parseColor(extrasRoot.getString("ledc"));
                customLight = true;
            } catch (Exception ex) {
                try {
                    argb = Integer.parseInt(extrasRoot.getString("ledc"));
                    customLight = true;
                } catch (NumberFormatException nfe) {
                }
            }
        }
        if (extras.containsKey("ledOnMS")) {
            try {
                onMs = Integer.parseInt(extras.getString("ledOnMS"));
                customLight = true;
            } catch (NumberFormatException nfe) {
            }
        }
        if (extras.containsKey("ledOffMS")) {
            try {
                offMs = Integer.parseInt(extras.getString("ledOffMS"));
                customLight = true;
            } catch (NumberFormatException nfe) {
            }
        }
        if (customLight) {
            mBuilder.setLights(argb, onMs, offMs);
        }

        //Visibility
        if (extras.containsKey("visibility")) {
            try {
                mBuilder.setVisibility(Integer.parseInt(extras.getString("visibility")));
            } catch (NumberFormatException nfe) {
            }
        } else if (extras.containsKey("vis")) {
            try {
                mBuilder.setVisibility(Integer.parseInt(extras.getString("vis")));
            } catch (NumberFormatException nfe) {
            }
        } else if (extrasRoot.containsKey("visibility")) {
            try {
                mBuilder.setVisibility(Integer.parseInt(extrasRoot.getString("visibility")));
            } catch (NumberFormatException nfe) {
            }
        } else if (extrasRoot.containsKey("vis")) {
            try {
                mBuilder.setVisibility(Integer.parseInt(extrasRoot.getString("vis")));
            } catch (NumberFormatException nfe) {
            }
        }

        //Icon background color
        int accent_argb = 0xFFFFFFFF;
        if (extras.containsKey("accentARGB")) {
            try {
                accent_argb = TiColorHelper.parseColor(extras.getString("accentARGB"));
                mBuilder.setColor(accent_argb);
            } catch (Exception ex) {
                try {
                    accent_argb = Integer.parseInt(extras.getString("accentARGB"));
                    mBuilder.setColor(accent_argb);
                } catch (NumberFormatException nfe) {
                }
            }
        } else if (extras.containsKey("bgac")) {
            try {
                accent_argb = TiColorHelper.parseColor(extras.getString("bgac"));
                mBuilder.setColor(accent_argb);
            } catch (Exception ex) {
                try {
                    accent_argb = Integer.parseInt(extras.getString("bgac"));
                    mBuilder.setColor(accent_argb);
                } catch (NumberFormatException nfe) {
                }
            }
        } else if (extrasRoot.containsKey("accentARGB")) {
            try {
                accent_argb = TiColorHelper.parseColor(extrasRoot.getString("accentARGB"));
                mBuilder.setColor(accent_argb);
            } catch (Exception ex) {
                try {
                    accent_argb = Integer.parseInt(extrasRoot.getString("accentARGB"));
                    mBuilder.setColor(accent_argb);
                } catch (NumberFormatException nfe) {
                }
            }
        } else if (extrasRoot.containsKey("bgac")) {
            try {
                accent_argb = TiColorHelper.parseColor(extrasRoot.getString("bgac"));
                mBuilder.setColor(accent_argb);
            } catch (Exception ex) {
                try {
                    accent_argb = Integer.parseInt(extrasRoot.getString("bgac"));
                    mBuilder.setColor(accent_argb);
                } catch (NumberFormatException nfe) {
                }
            }
        }

        NotificationManager nm = (NotificationManager) appContext
                .getSystemService(Context.NOTIFICATION_SERVICE);

        nm.notify(notificationId, mBuilder.build());
    }
}

From source file:cm.aptoide.pt.DownloadQueueService.java

private void setNotification(int apkidHash, int progress) {

    String apkid = notifications.get(apkidHash).get("apkid");
    int size = Integer.parseInt(notifications.get(apkidHash).get("intSize"));
    String version = notifications.get(apkidHash).get("version");

    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.download_notification);
    contentView.setImageViewResource(R.id.download_notification_icon, R.drawable.ic_notification);
    contentView.setTextViewText(R.id.download_notification_name,
            getString(R.string.download_alrt) + " " + apkid + " v." + version);
    contentView.setProgressBar(R.id.download_notification_progress_bar, size * KBYTES_TO_BYTES, progress,
            false);/*from  www.  j av  a 2  s .  co m*/

    Intent onClick = new Intent();
    onClick.setClassName("cm.aptoide.pt", "cm.aptoide.pt");
    onClick.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
    onClick.setAction("cm.aptoide.pt.FROM_NOTIFICATION");

    // The PendingIntent to launch our activity if the user selects this notification
    PendingIntent onClickAction = PendingIntent.getActivity(context, 0, onClick, 0);

    Notification notification = new Notification(R.drawable.ic_notification,
            getString(R.string.download_alrt) + " " + apkid, System.currentTimeMillis());
    notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
    notification.contentView = contentView;

    // Set the info for the notification panel.
    notification.contentIntent = onClickAction;
    //       notification.setLatestEventInfo(this, getText(R.string.app_name), getText(R.string.add_repo_text), contentIntent);

    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    // Send the notification.
    // We use the position because it is a unique number.  We use it later to cancel.
    notificationManager.notify(apkidHash, notification);

    //      Log.d("Aptoide-DownloadQueueService", "Notification Set");
}

From source file:org.wso2.iot.agent.services.MessageProcessor.java

@SuppressWarnings("unused")
@Override/*  www . j  a va 2s .c  o m*/
public void onReceiveAPIResult(Map<String, String> result, int requestCode) {
    String responseStatus;
    String response;
    if (requestCode == Constants.NOTIFICATION_REQUEST_CODE) {
        Preference.putLong(context, Constants.PreferenceFlag.LAST_SERVER_CALL,
                CommonUtils.currentDate().getTime());
        Intent intent = new Intent();
        intent.setAction(Constants.SYNC_BROADCAST_ACTION);
        context.sendBroadcast(intent);

        if (isWipeTriggered) {
            if (Constants.SYSTEM_APP_ENABLED) {
                CommonUtils.callSystemApp(context, Constants.Operation.WIPE_DATA, null, null);
            } else {
                Log.i(TAG, "Not the device owner.");
            }
        }

        if (isEnterpriseWipeTriggered) {
            CommonUtils.disableAdmin(context);

            Intent intentEnterpriseWipe = new Intent(context, ServerConfigsActivity.class);
            intentEnterpriseWipe.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intentEnterpriseWipe.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intentEnterpriseWipe);
            if (Constants.DEBUG_MODE_ENABLED) {
                Log.d(TAG, "Started enterprise wipe");
            }
        }

        if (isRebootTriggered) {
            CommonUtils.callSystemApp(context, Constants.Operation.REBOOT, null, null);
        }

        if (isUpgradeTriggered) {
            String schedule = Preference.getString(context,
                    context.getResources().getString(R.string.pref_key_schedule));
            CommonUtils.callSystemApp(context, Constants.Operation.UPGRADE_FIRMWARE, schedule, null);
        }

        if (isShellCommandTriggered && shellCommand != null) {
            CommonUtils.callSystemApp(context, Constants.Operation.EXECUTE_SHELL_COMMAND, shellCommand, null);
        }

        if (result != null) {
            responseStatus = result.get(Constants.STATUS_KEY);
            response = result.get(Constants.RESPONSE);
            if (Constants.Status.SUCCESSFUL.equals(responseStatus)
                    || Constants.Status.CREATED.equals(responseStatus)) {
                if (response != null && !response.isEmpty()) {
                    if (Constants.DEBUG_MODE_ENABLED) {
                        Log.d(TAG, "Pending Operations List: " + response);
                    }
                    if (Constants.DEFAULT_OWNERSHIP.equals(Constants.OWNERSHIP_COSU)) {
                        if (!Preference.getBoolean(context, Constants.PreferenceFlag.DEVICE_INITIALIZED)) {
                            Preference.putBoolean(context, Constants.PreferenceFlag.DEVICE_INITIALIZED, true);
                        }
                    }
                    performOperation(response);
                }
            } else if (Constants.Status.AUTHENTICATION_FAILED.equals(responseStatus)
                    && org.wso2.iot.agent.proxy.utils.Constants.REFRESH_TOKEN_EXPIRED.equals(response)) {
                Log.d(TAG, "Requesting credentials to obtain new token pair.");
                LocalNotification.stopPolling(context);
                Preference.putBoolean(context, Constants.TOKEN_EXPIRED, true);
                CommonUtils.displayNotification(context, R.drawable.ic_error_outline_white_24dp,
                        context.getResources().getString(R.string.title_need_to_sign_in),
                        context.getResources().getString(R.string.msg_need_to_sign_in),
                        AuthenticationActivity.class, Constants.TOKEN_EXPIRED,
                        Constants.SIGN_IN_NOTIFICATION_ID);
            }
        }
    }
}

From source file:de.lespace.apprtc.activity.ConnectActivity.java

private void connectToUser() {

    Intent newIntent = new Intent(this, CallActivity.class);
    newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    newIntent.putExtra("keep", true);
    newIntent.putExtras(intent);/*from   w w w  .ja v  a 2 s  .com*/
    startActivityForResult(newIntent, CONNECTION_REQUEST);

}

From source file:io.selendroid.server.ServerInstrumentation.java

public void backgroundActivity() {
    activitiesReporter.setBackgroundActivity(activitiesReporter.getCurrentActivity());
    Intent homeIntent = new Intent(Intent.ACTION_MAIN);
    homeIntent.addCategory(Intent.CATEGORY_HOME);
    homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    getTargetContext().startActivity(homeIntent);
}

From source file:com.polyvi.xface.extension.telephony.XTelephonyExt.java

/**
 * ???//from   w  ww .  ja v  a  2  s  . c  o  m
 *
 * @param[in] phoneNumber ????
 * @return ???
 */
private boolean initiateVoiceCall(String phoneNumber) {
    try {
        if (isLegalPhoneNum(phoneNumber)) {
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setData(Uri.parse(WebView.SCHEME_TEL + phoneNumber));
            mContext.startActivity(intent);
            return true;
        }
    } catch (ActivityNotFoundException e) {
        XLog.e(CLASS_NAME, e.toString());
    } catch (SecurityException e) {
        XLog.e(CLASS_NAME, e.toString());
    }
    return false;
}

From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.services.SystemMonitor.java

private int systemNotice() {
    int t = START_STICKY;
    Log.e(SystemMonitor.class.getSimpleName(), "call me redundant BABY!  onStartCommand service");

    int myID = android.os.Process.myPid();
    // The intent to launch when the user clicks the expanded notification
    Intent intent = new Intent(this, MyHealthHubWithFragments.class);
    // Intent intent = new Intent();
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0);

    Notification notice = new Notification.Builder(getApplicationContext()).setSmallIcon(R.drawable.ic_launcher)
            .setWhen(System.currentTimeMillis()).setContentTitle(getPackageName())
            .setContentText("System Monitor running").setContentIntent(pendIntent).getNotification();

    notice.flags |= Notification.FLAG_AUTO_CANCEL;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(myID, notice);

    return t;/* w w w. j  a v  a2  s. c  o  m*/
}

From source file:fr.bmartel.android.tictactoe.GameSingleton.java

public void acceptChallenge(final String challengerId, String challengerName) {

    Log.i(TAG, "send accept challenge request : "
            + RequestBuilder.buildChallengeResponse(DEVICE_ID, challengerName, challengerId));

    JsonObjectRequest jsObjRequest = new JsonObjectRequest(BuildConfig.APP_ROUTE + "/accept_challenge",
            RequestBuilder.buildChallengeResponse(DEVICE_ID, challengerName, challengerId),
            new Response.Listener<JSONObject>() {

                @Override/* ww  w  .  j av  a  2  s. c om*/
                public void onResponse(JSONObject response) {

                    Log.i(TAG, "response received accept challenge : " + response.toString());

                    // call to start game activity
                    playerTurn = false;
                    GameSingleton.this.challengerId = challengerId;
                    setSecondSign();
                    Intent intent2 = new Intent(context, GameActivity.class);
                    intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
                    context.startActivity(intent2);
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    error.printStackTrace();
                }
            });
    jsObjRequest.setShouldCache(false);
    queue.add(jsObjRequest);
}

From source file:com.joefernandez.irrduino.android.remote.IrrduinoRemoteActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final Intent intent;
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.preferences:
        intent = new Intent(this, Settings.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);//from  w  ww.  ja v a  2 s .  co m
        settingsChanged = true;
        return true;
    case R.id.report:
        intent = new Intent(this, ViewReportActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}