Example usage for android.content Intent FLAG_ACTIVITY_SINGLE_TOP

List of usage examples for android.content Intent FLAG_ACTIVITY_SINGLE_TOP

Introduction

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

Prototype

int FLAG_ACTIVITY_SINGLE_TOP

To view the source code for android.content Intent FLAG_ACTIVITY_SINGLE_TOP.

Click Source Link

Document

If set, the activity will not be launched if it is already running at the top of the history stack.

Usage

From source file:com.android.calendar.AllInOneActivity.java

@Override
public void handleEvent(EventInfo event) {
    long displayTime = -1;
    if (event.eventType == EventType.GO_TO) {
        if ((event.extraLong & CalendarController.EXTRA_GOTO_BACK_TO_PREVIOUS) != 0) {
            mBackToPreviousView = true;/*from  ww  w.  j a v a  2 s  . c  o m*/
        } else if (event.viewType != mController.getPreviousViewType() && event.viewType != ViewType.EDIT) {
            // Clear the flag is change to a different view type
            mBackToPreviousView = false;
        }

        setMainPane(null, R.id.main_pane, event.viewType, event.startTime.toMillis(false), false);
        if (mSearchView != null) {
            mSearchView.clearFocus();
        }
        if (mShowCalendarControls) {
            int animationSize = (mOrientation == Configuration.ORIENTATION_LANDSCAPE) ? mControlsAnimateWidth
                    : mControlsAnimateHeight;
            boolean noControlsView = event.viewType == ViewType.MONTH || event.viewType == ViewType.AGENDA;
            if (mControlsMenu != null) {
                mControlsMenu.setVisible(!noControlsView);
                mControlsMenu.setEnabled(!noControlsView);
            }
            if (noControlsView || mHideControls) {
                // hide minimonth and calendar frag
                mShowSideViews = false;
                if (!mHideControls) {
                    final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset", 0,
                            animationSize);
                    slideAnimation.addListener(mSlideAnimationDoneListener);
                    slideAnimation.setDuration(mCalendarControlsAnimationTime);
                    ObjectAnimator.setFrameDelay(0);
                    slideAnimation.start();
                } else {
                    mMiniMonth.setVisibility(View.GONE);
                    mCalendarsList.setVisibility(View.GONE);
                    mMiniMonthContainer.setVisibility(View.GONE);
                }
            } else {
                // show minimonth and calendar frag
                mShowSideViews = true;
                mMiniMonth.setVisibility(View.VISIBLE);
                mCalendarsList.setVisibility(View.VISIBLE);
                mMiniMonthContainer.setVisibility(View.VISIBLE);
                if (!mHideControls && (mController.getPreviousViewType() == ViewType.MONTH
                        || mController.getPreviousViewType() == ViewType.AGENDA)) {
                    final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset",
                            animationSize, 0);
                    slideAnimation.setDuration(mCalendarControlsAnimationTime);
                    ObjectAnimator.setFrameDelay(0);
                    slideAnimation.start();
                }
            }
        }
        displayTime = event.selectedTime != null ? event.selectedTime.toMillis(true)
                : event.startTime.toMillis(true);
        if (!mIsTabletConfig) {
            refreshActionbarTitle(displayTime);
        }
    } else if (event.eventType == EventType.VIEW_EVENT) {

        // If in Agenda view and "show_event_details_with_agenda" is "true",
        // do not create the event info fragment here, it will be created by the Agenda
        // fragment

        if (mCurrentView == ViewType.AGENDA && mShowEventDetailsWithAgenda) {
            if (event.startTime != null && event.endTime != null) {
                // Event is all day , adjust the goto time to local time
                if (event.isAllDay()) {
                    Utils.convertAlldayUtcToLocal(event.startTime, event.startTime.toMillis(false), mTimeZone);
                    Utils.convertAlldayUtcToLocal(event.endTime, event.endTime.toMillis(false), mTimeZone);
                }
                mController.sendEvent(this, EventType.GO_TO, event.startTime, event.endTime, event.selectedTime,
                        event.id, ViewType.AGENDA, CalendarController.EXTRA_GOTO_TIME, null, null);
            } else if (event.selectedTime != null) {
                mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, event.id,
                        ViewType.AGENDA);
            }
        } else {
            // TODO Fix the temp hack below: && mCurrentView !=
            // ViewType.AGENDA
            if (event.selectedTime != null && mCurrentView != ViewType.AGENDA) {
                mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, -1,
                        ViewType.CURRENT);
            }
            int response = event.getResponse();
            if ((mCurrentView == ViewType.AGENDA && mShowEventInfoFullScreenAgenda)
                    || ((mCurrentView == ViewType.DAY || (mCurrentView == ViewType.WEEK)
                            || mCurrentView == ViewType.MONTH) && mShowEventInfoFullScreen)) {
                // start event info as activity
                Intent intent = new Intent(Intent.ACTION_VIEW);
                Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, event.id);
                intent.setData(eventUri);
                intent.setClass(this, EventInfoActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                intent.putExtra(EXTRA_EVENT_BEGIN_TIME, event.startTime.toMillis(false));
                intent.putExtra(EXTRA_EVENT_END_TIME, event.endTime.toMillis(false));
                intent.putExtra(ATTENDEE_STATUS, response);
                startActivity(intent);
            } else {
                // start event info as a dialog
                EventInfoFragment fragment = new EventInfoFragment(this, event.id,
                        event.startTime.toMillis(false), event.endTime.toMillis(false), response, true,
                        EventInfoFragment.DIALOG_WINDOW_STYLE, null /* No reminders to explicitly pass in. */);
                fragment.setDialogParams(event.x, event.y, mActionBar.getHeight());
                FragmentManager fm = getFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                // if we have an old popup replace it
                Fragment fOld = fm.findFragmentByTag(EVENT_INFO_FRAGMENT_TAG);
                if (fOld != null && fOld.isAdded()) {
                    ft.remove(fOld);
                }
                ft.add(fragment, EVENT_INFO_FRAGMENT_TAG);
                ft.commit();
            }
        }
        displayTime = event.startTime.toMillis(true);
    } else if (event.eventType == EventType.UPDATE_TITLE) {
        setTitleInActionBar(event);
        if (!mIsTabletConfig) {
            refreshActionbarTitle(mController.getTime());
        }
    }
    updateSecondaryTitleFields(displayTime);
}

From source file:com.amaze.filemanager.fragments.Main.java

private void addShortcut(Layoutelements path) {
    //Adding shortcut for MainActivity
    //on Home screen
    Intent shortcutIntent = new Intent(getActivity().getApplicationContext(), MainActivity.class);
    shortcutIntent.putExtra("path", path.getDesc());
    shortcutIntent.setAction(Intent.ACTION_MAIN);
    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    Intent addIntent = new Intent();
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, new File(path.getDesc()).getName());

    addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            Intent.ShortcutIconResource.fromContext(getActivity(), R.mipmap.ic_launcher));

    addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    getActivity().sendBroadcast(addIntent);
}

From source file:com.amaze.filemanager.fragments.MainFragment.java

private void addShortcut(LayoutElementParcelable path) {
    //Adding shortcut for MainActivity
    //on Home screen
    final Context ctx = getContext();

    if (!ShortcutManagerCompat.isRequestPinShortcutSupported(ctx)) {
        Toast.makeText(getActivity(), getString(R.string.addshortcut_not_supported_by_launcher),
                Toast.LENGTH_SHORT).show();
        return;//from w w w .ja  v  a 2s.  c o m
    }

    Intent shortcutIntent = new Intent(ctx, MainActivity.class);
    shortcutIntent.putExtra("path", path.desc);
    shortcutIntent.setAction(Intent.ACTION_MAIN);
    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    // Using file path as shortcut id.
    ShortcutInfoCompat info = new ShortcutInfoCompat.Builder(ctx, path.desc)
            .setActivity(getMainActivity().getComponentName())
            .setIcon(IconCompat.createWithResource(ctx, R.mipmap.ic_launcher)).setIntent(shortcutIntent)
            .setLongLabel(path.desc).setShortLabel(new File(path.desc).getName()).build();

    ShortcutManagerCompat.requestPinShortcut(ctx, info, null);
}

From source file:com.instiwork.RegistrationActivity.java

public void FB_ChkUser(final String URL, final JSONObject jObject) {

    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, URL, null,
            new Response.Listener<JSONObject>() {
                @Override//from  w  w  w . j  a  va2s .co  m
                public void onResponse(JSONObject response) {
                    Logger.showMessage(TAG, URL);
                    Logger.showMessage(TAG, response.toString());

                    ll_image_selection.setEnabled(true);
                    txt_terms_conditions.setEnabled(true);
                    findViewById(R.id.footer).setEnabled(true);
                    findViewById(R.id.help_password).setEnabled(true);
                    findViewById(R.id.help_dob).setEnabled(true);
                    findViewById(R.id.help_license).setEnabled(true);

                    ll_license.setEnabled(true);
                    findViewById(R.id.loginBttn).setEnabled(true);
                    findViewById(R.id.fb_log).setEnabled(true);
                    dateOfBirth.setEnabled(true);
                    ll_image_selection.setClickable(true);
                    txt_terms_conditions.setClickable(true);
                    findViewById(R.id.footer).setClickable(true);
                    findViewById(R.id.help_password).setClickable(true);
                    findViewById(R.id.help_dob).setClickable(true);
                    findViewById(R.id.help_license).setClickable(true);

                    ll_license.setClickable(true);
                    findViewById(R.id.loginBttn).setClickable(true);
                    findViewById(R.id.fb_log).setClickable(true);
                    dateOfBirth.setClickable(true);

                    try {
                        if (response.getJSONObject("response").getString("status")
                                .equalsIgnoreCase("Success")) {

                            LoginManager.getInstance().logOut();

                            pDialogOut.hide();
                            InstiworkApplication.getInstance()
                                    .setUSER_ID(response.getJSONObject("response").getString("userid"));
                            InstiworkApplication.getInstance()
                                    .setUSER_NAME(response.getJSONObject("response").getString("Company_name"));
                            InstiworkApplication.getInstance()
                                    .setUSER_EMAIL(response.getJSONObject("response").getString("email"));
                            //                                InstiworkApplication.getInstance().setUSER_IMG("https://graph.facebook.com/" + jObject.getString("id") + "/picture?type=large");
                            InstiworkApplication.getInstance()
                                    .setMOBILE_NO(response.getJSONObject("response").getString("email"));
                            InstiworkApplication.getInstance().setUSER_IMG(
                                    (response.getJSONObject("response").getString("profileimage")));

                            try {
                                InstiworkApplication.getInstance().setPush_status(
                                        response.getJSONObject("response").getString("push_status"));
                                InstiworkApplication.getInstance().setEmail_status(
                                        response.getJSONObject("response").getString("email_status"));
                                InstiworkApplication.getInstance().setText_status(
                                        response.getJSONObject("response").getString("text_status"));
                                InstiworkApplication.getInstance().setCountryid(
                                        response.getJSONObject("response").getString("country_id"));
                                InstiworkApplication.getInstance().setCurrency_id(
                                        response.getJSONObject("response").getString("currency_id"));
                                InstiworkApplication.getInstance().setCountry_name(
                                        response.getJSONObject("response").getString("country_name"));
                                InstiworkApplication.getInstance().setCountry_3_code(
                                        response.getJSONObject("response").getString("country_3_code"));
                                InstiworkApplication.getInstance().setCountry_2_code(
                                        response.getJSONObject("response").getString("country_2_code"));
                                InstiworkApplication.getInstance().setCurrency_code(
                                        response.getJSONObject("response").getString("currency_code"));
                                InstiworkApplication.getInstance().setCurrency_name(
                                        response.getJSONObject("response").getString("currency_name"));
                                InstiworkApplication.getInstance().setMember_since(
                                        response.getJSONObject("response").getString("member_since"));

                            } catch (Exception e) {
                                Logger.showMessage(TAG, "Extra Paremeter : " + e.toString());
                            }

                            if (response.getJSONObject("response").getString("contact").equalsIgnoreCase("0")) {
                                InstiworkApplication.getInstance().setMOBILE_NO("");
                            } else {
                                InstiworkApplication.getInstance()
                                        .setMOBILE_NO(response.getJSONObject("response").getString("contact"));
                            }
                            InstiworkApplication.getInstance().setJOB_SEARCH_RADIUS(
                                    response.getJSONObject("response").getString("distance_user"));
                            InstiworkApplication.getInstance()
                                    .setUnit_user(response.getJSONObject("response").getString("unit_user"));
                            try {
                                licenseLinkedList = new LinkedList<JSONObject>();
                                if (response.getJSONObject("response").getJSONArray("license").length() > 0) {
                                    for (int i = 0; i < response.getJSONObject("response")
                                            .getJSONArray("license").length(); i++) {
                                        licenseLinkedList.add(response.getJSONObject("response")
                                                .getJSONArray("license").getJSONObject(i));
                                    }
                                    InstiworkApplication.getInstance().setLicenseArray(licenseLinkedList);
                                } else {
                                    InstiworkApplication.getInstance().setLicenseArray(null);
                                }
                            } catch (Exception e) {
                                InstiworkApplication.getInstance().setLicenseArray(null);
                                Logger.showMessage(TAG, "license Exception" + e.toString());
                            }

                            SharedPreferences.Editor edit = appSharedPref.edit();
                            edit.putString("USER_ID", response.getJSONObject("response").getString("userid"));
                            try {
                                edit.putString("CURRENCY_ID",
                                        response.getJSONObject("response").getString("currency_id"));
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            edit.commit();

                            try {
                                Map<String, Object> params = new HashMap<>();
                                params.put("action", "facebook_login");
                                params.put("action_user_id", InstiworkApplication.getInstance().getUSER_ID());
                                params.put("action_user_name",
                                        InstiworkApplication.getInstance().getUSER_NAME());
                                AdWordsRemarketingReporter.reportWithConversionId(getApplicationContext(),
                                        getResources().getString(R.string.conversion_id), params);
                                params.put("action_device", "android");
                            } catch (Exception e) {
                                Logger.showMessage(TAG, "AdWords : " + e.toString());
                            }

                            Intent i = new Intent(getApplicationContext(), LandingActivity.class);
                            Toast.makeText(RegistrationActivity.this, "Registered successfully",
                                    Toast.LENGTH_SHORT).show();
                            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP
                                    | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                            startActivity(i);
                            finish();

                        } else {
                            Toast.makeText(RegistrationActivity.this, "New User Register First.",
                                    Toast.LENGTH_SHORT).show();

                            Intent fbIntent = new Intent(RegistrationActivity.this,
                                    RegistrationFacebookActivity.class);
                            fbIntent.putExtra("FromIntent", "RegistrationActivity");
                            fbIntent.putExtra("FB_ID", "" + jObject.getString("id"));
                            fbIntent.putExtra("FB_ACCESS_TOKEN", "" + fbAccessToken);
                            fbIntent.putExtra("FB_DEVICE_TOKEN", "" + gcmToken);
                            try {
                                fbIntent.putExtra("FB_NAME", "" + jObject.getString("first_name") + " "
                                        + jObject.getString("last_name"));
                            } catch (Exception ee) {
                                fbIntent.putExtra("FB_NAME", "");
                            }
                            try {
                                fbIntent.putExtra("FB_EMAIL", "" + jObject.getString("email"));
                            } catch (Exception ee) {
                                fbIntent.putExtra("FB_EMAIL", "");
                            }
                            try {
                                fbIntent.putExtra("FB_BIRTHDAY", "" + jObject.getString("birthday"));
                            } catch (Exception ee) {
                                fbIntent.putExtra("FB_BIRTHDAY", "");
                            }
                            try {
                                fbIntent.putExtra("FB_GENDER", "" + jObject.getString("gender"));
                            } catch (Exception ee) {
                                fbIntent.putExtra("FB_GENDER", "");
                            }
                            try {
                                fbIntent.putExtra("FB_IMG", "" + "https://graph.facebook.com/"
                                        + jObject.getString("id") + "/picture?type=large");
                            } catch (Exception ee) {
                                fbIntent.putExtra("FB_IMG", "");
                            }
                            startActivity(fbIntent);
                            finish();
                        }

                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    Logger.showMessage(TAG, "Error: " + error.getMessage());
                    pDialogOut.hide();

                    ll_image_selection.setEnabled(true);
                    txt_terms_conditions.setEnabled(true);
                    findViewById(R.id.footer).setEnabled(true);
                    findViewById(R.id.help_password).setEnabled(true);
                    findViewById(R.id.help_dob).setEnabled(true);
                    findViewById(R.id.help_license).setEnabled(true);

                    ll_license.setEnabled(true);
                    findViewById(R.id.loginBttn).setEnabled(true);
                    findViewById(R.id.fb_log).setEnabled(true);
                    dateOfBirth.setEnabled(true);
                    ll_image_selection.setClickable(true);
                    txt_terms_conditions.setClickable(true);
                    findViewById(R.id.footer).setClickable(true);
                    findViewById(R.id.help_password).setClickable(true);
                    findViewById(R.id.help_dob).setClickable(true);
                    findViewById(R.id.help_license).setClickable(true);

                    ll_license.setClickable(true);
                    findViewById(R.id.loginBttn).setClickable(true);
                    findViewById(R.id.fb_log).setClickable(true);
                    dateOfBirth.setClickable(true);

                    if (error instanceof NoConnectionError) {
                        android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(
                                RegistrationActivity.this);
                        builder.setTitle("Instiwork");
                        builder.setMessage("You do not have internet connection!");
                        builder.setPositiveButton("retry", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.dismiss();
                                pDialogOut.show();

                                ll_image_selection.setEnabled(false);
                                txt_terms_conditions.setEnabled(false);
                                findViewById(R.id.footer).setEnabled(false);
                                findViewById(R.id.help_password).setEnabled(false);
                                findViewById(R.id.help_dob).setEnabled(false);
                                findViewById(R.id.help_license).setEnabled(false);

                                ll_license.setEnabled(false);
                                findViewById(R.id.loginBttn).setEnabled(false);
                                findViewById(R.id.fb_log).setEnabled(false);
                                dateOfBirth.setEnabled(false);
                                ll_image_selection.setClickable(false);
                                txt_terms_conditions.setClickable(false);
                                findViewById(R.id.footer).setClickable(false);
                                findViewById(R.id.help_password).setClickable(false);
                                findViewById(R.id.help_dob).setClickable(false);
                                findViewById(R.id.help_license).setClickable(false);

                                ll_license.setClickable(false);
                                findViewById(R.id.loginBttn).setClickable(false);
                                findViewById(R.id.fb_log).setClickable(false);
                                dateOfBirth.setClickable(false);

                                FB_ChkUser(URL, jObject);
                            }
                        });
                        builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.dismiss();
                            }
                        });
                        builder.setCancelable(false);
                        builder.show();
                    } else {
                        try {
                            String json = null;
                            NetworkResponse response = error.networkResponse;
                            if (response != null && response.data != null) {
                                json = new String(response.data);
                                json = trimMessage(json, "message");
                                if (json != null)
                                    //                                displayMessage(json);
                                    displayMessage(json + " Error Code : " + response.statusCode);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            });
    jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    InstiworkApplication.getInstance().addToRequestQueue(jsonObjReq);
}

From source file:com.wso2.mobile.mdm.services.Operation.java

/**
 * Issues a notification to inform the user that server has sent a message.
 */// ww w .j a v a  2s.  c  o m
private static void generateNotification(Context context, String message) {
    int icon = R.drawable.ic_stat_gcm;
    long when = System.currentTimeMillis();
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(icon, message, when);
    String title = context.getString(R.string.app_name);
    Intent notificationIntent = new Intent(context, NotifyActivity.class);
    notificationIntent.putExtra("notification", message);
    // 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.setLatestEventInfo(context, title, message, intent);
    notification.flags |= Notification.FLAG_SHOW_LIGHTS;
    notificationManager.notify(0, notification);
    Toast.makeText(context, message, Toast.LENGTH_LONG).show();
}

From source file:com.ferdi2005.secondgram.voip.VoIPService.java

public void onUIForegroundStateChanged(boolean isForeground) {
    if (currentState == STATE_WAITING_INCOMING) {
        if (isForeground) {
            stopForeground(true);/*w w w .  j  a va2 s . c om*/
        } else {
            if (!((KeyguardManager) getSystemService(KEYGUARD_SERVICE)).inKeyguardRestrictedInputMode()) {
                showIncomingNotification();
            } else {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        Intent intent = new Intent(VoIPService.this, VoIPActivity.class);
                        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                        try {
                            PendingIntent.getActivity(VoIPService.this, 0, intent, 0).send();
                        } catch (PendingIntent.CanceledException e) {
                            FileLog.e("error restarting activity", e);
                        }
                    }
                }, 500);
            }
        }
    }
}

From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java

private void addShortcut(LayoutElement path) {
    //Adding shortcut for MainActivity
    //on Home screen
    Intent shortcutIntent = new Intent(getActivity().getApplicationContext(), MainActivity.class);
    shortcutIntent.putExtra("path", path.getDesc());
    shortcutIntent.setAction(Intent.ACTION_MAIN);
    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    Intent addIntent = new Intent();
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, new File(path.getDesc()).getName());

    addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            Intent.ShortcutIconResource.fromContext(getActivity(), R.mipmap.ic_launcher));

    addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    getActivity().sendBroadcast(addIntent);
}

From source file:de.rosche.spectraTelemetry.SpectraTelemetry.java

private void doService() {

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.aurorasmall).setContentTitle("Hitec Telemetry Service")
            .setContentText("started...");
    int NOTIFICATION_ID = 12346;

    Intent targetIntent = new Intent(this, SpectraTelemetry.class);
    targetIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, targetIntent, 0);
    builder.setContentIntent(contentIntent);
    NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nManager.notify(NOTIFICATION_ID, builder.build());

    Intent intent = new Intent(this, SpeakService.class);
    pendingIntent = PendingIntent.getService(this, 0, intent, 0);
    Calendar cal = Calendar.getInstance();
    AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 10 * 1000, pendingIntent);
}

From source file:co.beem.project.beem.FbTextService.java

private PendingIntent makeChatIntent(User user) {
    Intent chatIntent = new Intent(FbTextService.this, FbTextMainActivity.class);
    chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP
            | Intent.FLAG_ACTIVITY_NEW_TASK);
    try {/*from   www  . j  av a 2  s.c  o  m*/
        chatIntent.setData(user.toUri());
    } catch (Exception e) {
        if (FbTextApplication.isDebug)
            Log.e(TAG, e.getMessage());
    }
    PendingIntent contentIntent = PendingIntent.getActivity(FbTextService.this, 0, chatIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    return contentIntent;
}

From source file:com.android.mms.transaction.MessagingNotification.java

/**
 * Return the intent of multi-unread messges notification.
 */// w  w w.  j  a v  a 2  s.c  o  m
public static Intent getMultiThreadsViewIntent(Context context) {
    Intent intent;
    if (MessageUtils.isMailboxMode()) {
        intent = new Intent(context, MailBoxMessageList.class);
        intent.putExtra(MessageUtils.MAIL_BOX_ID, MailBoxMessageList.TYPE_INBOX);
    } else {
        intent = new Intent(context, ConversationList.class);
    }
    intent.setFlags(
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);

    return intent;
}