Example usage for android.content Intent addFlags

List of usage examples for android.content Intent addFlags

Introduction

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

Prototype

public @NonNull Intent addFlags(@Flags int flags) 

Source Link

Document

Add additional flags to the intent (or with existing flags value).

Usage

From source file:com.getmarco.weatherstationviewer.gcm.StationGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from  www  .j  a  va  2  s.c om
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, StationListActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Station update").setContentText(message)
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:com.android.cts.browser.BrowserBenchTest.java

private void doTest(String url, ResultType typeNonFinal, ResultUnit unitNonFinal, ResultType typeFinal,
        ResultUnit unitFinal, int numberRepeat) throws InterruptedException {
    mTypeNonFinal = typeNonFinal;/*  w  ww. java 2  s .  co m*/
    mUnitNonFinal = unitNonFinal;
    mTypeFinal = typeFinal;
    mUnitFinal = unitFinal;
    mNumberRepeat = numberRepeat;
    Uri uri = Uri.parse(url);
    for (mRunIndex = 0; mRunIndex < numberRepeat; mRunIndex++) {
        Log.i(TAG, mRunIndex + "-th round");
        mLatch = new CountDownLatch(1);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // force using only one window or tab
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, getContext().getPackageName());
        getContext().startActivity(intent);
        boolean ok = mLatch.await(BROWSER_COMPLETION_TIMEOUT_IN_MS, TimeUnit.MILLISECONDS);
        assertTrue("timed-out", ok);
    }
    // it is somewhat awkward to handle the last one specially with Map
    int numberEntries = mResultsMap.size();
    int numberToProcess = 1;
    for (Map.Entry<String, double[]> entry : mResultsMap.entrySet()) {
        String message = entry.getKey();
        double[] scores = entry.getValue();
        if (numberToProcess == numberEntries) { // final score
            // store the whole results first
            getReportLog().printArray(message, scores, mTypeFinal, mUnitFinal);
            getReportLog().printSummary(message, Stat.getAverage(scores), mTypeFinal, mUnitFinal);
        } else { // interim results
            getReportLog().printArray(message, scores, mTypeNonFinal, mUnitNonFinal);
        }
        numberToProcess++;
    }
}

From source file:com.oakesville.mythling.MediaListActivity.java

@Override
public void onBackPressed() {
    if (modeSwitch) {
        modeSwitch = false;/* w w  w  .j  a va  2  s  .com*/
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        finish();
    } else {
        super.onBackPressed();
    }
}

From source file:com.parse.loginsample.withdispatchactivity.SampleProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_profile);
    titleTextView = (TextView) findViewById(R.id.profile_title);
    emailTextView = (TextView) findViewById(R.id.profile_email);
    nameTextView = (TextView) findViewById(R.id.profile_name);
    titleTextView.setText(R.string.profile_title_logged_in);

    findViewById(R.id.logout_button).setOnClickListener(new OnClickListener() {
        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        @Override/*from  w ww . ja v  a 2s.c  o  m*/
        public void onClick(View v) {
            ParseUser.logOut();

            // FLAG_ACTIVITY_CLEAR_TASK only works on API 11, so if the user
            // logs out on older devices, we'll just exit.
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                Intent intent = new Intent(SampleProfileActivity.this, SampleDispatchActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            } else {
                finish();
            }
        }
    });

    getFbEvents();
}

From source file:fr.bmartel.android.tictactoe.gcm.MyGcmListenerService.java

/**
 * Called when message is received./*from   w ww  .  ja va2 s  . co  m*/
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {

    String message = data.getString("message");

    if (from.startsWith("/topics/" + GameSingleton.DEVICE_ID)) {
        Log.d(TAG, "Message: " + message);

        try {

            JSONObject object = new JSONObject(message);

            ArrayList<String> eventItem = new ArrayList<>();
            eventItem.add(object.toString());

            broadcastUpdateStringList(BroadcastFilters.EVENT_MESSAGE, eventItem);

            if (!GameSingleton.activityForeground) {

                if (object.has(RequestConstants.DEVICE_MESSAGE_TOPIC)
                        && object.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID)
                        && object.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)) {

                    GameMessageTopic topic = GameMessageTopic
                            .getTopic(object.getInt(RequestConstants.DEVICE_MESSAGE_TOPIC));

                    ChallengeMessage challengeMessage = new ChallengeMessage(topic,
                            object.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID),
                            object.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME));

                    Log.i(TAG, "challenged by " + challengeMessage.getChallengerName() + " : "
                            + challengeMessage.getChallengerId());

                    Intent intent2 = new Intent(this, DeviceListActivity.class);
                    intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent2,
                            PendingIntent.FLAG_ONE_SHOT);
                    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Fight!")
                            .setContentText("challenged by " + challengeMessage.getChallengerName())
                            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);
                    NotificationManager notificationManager = (NotificationManager) getSystemService(
                            Context.NOTIFICATION_SERVICE);
                    notificationManager.notify(new Random().nextInt(9999), notificationBuilder.build());

                    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
                    boolean isScreenOn = pm.isScreenOn();
                    if (isScreenOn == false) {
                        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
                                | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "MyLock");
                        wl.acquire(10000);
                        PowerManager.WakeLock wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
                                "MyCpuLock");
                        wl_cpu.acquire(10000);
                    }

                    GameSingleton.pendingChallengeMessage = challengeMessage;
                    GameSingleton.pendingChallenge = true;
                }
            }

        } catch (JSONException e) {
            e.printStackTrace();

        }
    }
}

From source file:com.cssweb.android.common.FairyUI.java

public static Intent genIntent(int paramInt1, int paramInt2, String paramString2, String paramString3,
        Context paramContext) {// w  ww . j av a2  s .  co  m
    Intent localIntent = new Intent();
    if (paramInt1 == Global.NJZQ_WTJY) {
        localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        // ?
        switch (paramInt2) {
        case 0:
            localIntent.setClass(paramContext, AccountManage.class);
            break;
        case 1:
            localIntent.putExtra("type", 0);
            localIntent.putExtra("bsname", "");
            localIntent.putExtra("stkcode", paramString2);
            localIntent.setClass(paramContext, StockTrading.class);
            break;
        case 2:
            localIntent.putExtra("type", 1);
            localIntent.putExtra("bsname", "?");
            localIntent.putExtra("stkcode", paramString2);
            localIntent.setClass(paramContext, StockTrading.class);
            break;
        case 3:
            localIntent.setClass(paramContext, StockCancel.class);
            break;
        case 4:
            localIntent.putExtra("menu_id", Global.NJZQ_WTJY_FIVE);
            localIntent.setClass(paramContext, BankActivity.class);
            break;
        case 5:
            localIntent.putExtra("type", Global.QUERY_STOCK_DRWT);
            localIntent.setClass(paramContext, TodayEntrust.class);
            break;
        case 6:
            localIntent.putExtra("type", Global.QUERY_STOCK_DRCJ);
            localIntent.setClass(paramContext, TodayDeal.class);
            break;
        case 7:
            localIntent.setClass(paramContext, GetPosition.class);
            break;
        case 8:
            localIntent.setClass(paramContext, AssetQuery.class);
            break;
        }
    } else if (paramInt1 == Global.NJZQ_WTJY_TWO) {
        localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        // ?
        switch (paramInt2) {
        case 0:
            localIntent.putExtra("menuid", Global.OPEN_GP);
            localIntent.putExtra("menudetail", Global.QUERY_STOCK_DZD);
            localIntent.setClass(paramContext, DateRange.class);
            break;
        case 1:
            localIntent.putExtra("menuid", Global.OPEN_GP);
            localIntent.putExtra("menudetail", Global.QUERY_STOCK_LSWT);
            localIntent.setClass(paramContext, DateRange.class);
            break;
        case 2:
            localIntent.putExtra("menu_id", Global.NJZQ_WTJY_GP_THREE);
            localIntent.setClass(paramContext, FundActivity.class);
            break;
        case 3:
            localIntent.putExtra("menu_id", Global.NJZQ_WTJY_GP_ONE);
            localIntent.setClass(paramContext, CnjjActivity.class);
            break;
        case 4:
            localIntent.putExtra("pos", Global.NJZQ_WTJY_SZLC);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 5:
            localIntent.putExtra("pos", Global.NJZQ_WTJY_RZRQ);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 6:
            localIntent.putExtra("menuid", Global.OPEN_GP);
            localIntent.putExtra("menudetail", Global.QUERY_NEW_STOCK_MATCH);
            localIntent.setClass(paramContext, DateRange.class);
            break;
        case 7:
            localIntent.setClass(paramContext, ModifyPassword.class);
            break;
        case 8:
            localIntent.setClass(paramContext, ShareholderList.class);
            break;
        }
    } else if (paramInt1 == Global.NJZQ_WTJY_THREE) {
        localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        switch (paramInt2) {
        case 0:
            localIntent.setClass(paramContext, ModifyContactInfo.class);
            break;
        }
    } else if (paramInt1 == Global.NJZQ_HQBJ) {
        if (!isNetworkErrorGoInActivity(paramContext)) {
            //            localIntent.putExtra("restart", 2);
            //            localIntent.setClass(paramContext, RestartDialog.class);
            loadAllStock(paramInt1, paramInt2, paramString2, paramString3, paramContext);
            localIntent = null;
        } else {
            localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            switch (paramInt2) {
            case 0:
                localIntent = genIsLoginIntent(Global.NJZQ_HQBJ_HQYJ, Global.NJZQ_HQBJ_HQYJ, paramContext);
                break;
            case 1:
                // 
                // localIntent.putExtra("requestType", 1);
                // localIntent.setClass(paramContext, PersonalStock.class);
                if (TradeUser.getInstance().getLoginType() == 3) {
                    localIntent.putExtra("requestType", 1);
                    localIntent.setClass(paramContext, PersonalStock.class);
                } else
                    localIntent = genIsLoginIntent(Global.QUOTE_USERSTK, Global.QUOTE_USERSTK, paramContext);
                break;
            case 2:
                localIntent.putExtra("requestType", 2);
                localIntent.setClass(paramContext, DaPan.class);
                break;
            case 3:
                localIntent.putExtra("requestType", 0);
                localIntent.setClass(paramContext, PaiMing.class);
                break;
            case 4:
                localIntent.putExtra("menuid", Global.QUOTE_FENSHI);
                localIntent.setClass(paramContext, QueryStock.class);
                break;
            case 5:
                localIntent.putExtra("requestType", 2);
                localIntent.setClass(paramContext, FenLei.class);
                break;
            case 6:
                localIntent.putExtra("menu_id", Global.NJZQ_HQBJ_EGHT);
                localIntent.setClass(paramContext, OTCFundActivity.class);
                break;
            case 7:
                localIntent.putExtra("menu_id", Global.NJZQ_HQBJ_FIVE);
                localIntent.setClass(paramContext, GlobalMarketActivity.class);
                break;
            case 8:
                localIntent.putExtra("menu_id", Global.NJZQ_HQBJ_QHHQ);
                localIntent.setClass(paramContext, QHHQActivity.class);
                break;
            }
        }
    } else if (paramInt1 == Global.NJZQ_ZXHD) {
        switch (paramInt2) {
        case 0:// 
            localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            localIntent.putExtra("pos", Global.NJZQ_ZXHD_ZJJP);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 1://
            localIntent = genIsLoginIntent(Global.NJZQ_ZXHD_TZGW, Global.NJZQ_ZXHD_TZGW, paramContext);
            break;
        case 2://??
            if (TradeUser.getInstance().getLoginType() == 3) {
                localIntent.putExtra("pos", Global.NJZQ_ZXHD_KHJL);
                localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                localIntent.setClass(paramContext, WebViewDisplay.class);
            } else
                localIntent = genIsLoginIntent(Global.NJZQ_ZXHD_KHJL, Global.NJZQ_ZXHD_KHJL, paramContext);
            break;
        case 3:// ?
            localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            localIntent.putExtra("pos", Global.NJZQ_ZXHD_ZXKF);// ?
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 4:// ?
            localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            localIntent.putExtra("pos", Global.NJZQ_ZXHD_KFRX);// ?
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 5:// 
            localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            localIntent.putExtra("pos", Global.NJZQ_ZXHD_GNLY);// 
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 6:// ?
            localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            localIntent.putExtra("pos", Global.NJZQ_ZXHD_CJWT);// ?
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 7:
            localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            localIntent.putExtra("menu_id", Global.NJZQ_ZXHD_EGHT);// 
            localIntent.setClass(paramContext, VistualTrade.class);
            break;
        default:
            localIntent = null;
            break;
        }
    } else if (paramInt1 == Global.NJZQ_NZFC) {// ??
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        switch (paramInt2) {
        case 0:
            localIntent.putExtra("pos", Global.NJZQ_NZFC_NZDT);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 1:
            localIntent.putExtra("pos", Global.NJZQ_NZFC_ZJNZ);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 2:
            localIntent.putExtra("pos", Global.NJZQ_NZFC_JYH);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        default:
            localIntent = null;
            break;
        }
    } else if (paramInt1 == Global.NJZQ_NZBD) {// ???
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        switch (paramInt2) {
        case 0:// ?
            localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            localIntent.putExtra("menu_id", Global.NJZQ_NZBD_JXZQC);
            localIntent.setClass(paramContext, JxgpcActivity.class);
            break;
        case 1:
            localIntent.putExtra("pos", Global.NJZQ_NZBD_TZZH);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 2:
            localIntent.putExtra("pos", Global.NJZQ_NZBD_ZQYJ);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 3:
            localIntent.putExtra("pos", Global.NJZQ_NZBD_QHYJ);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 4:// ?
            localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            localIntent.putExtra("menu_id", Global.NJZQ_NZBD_CFPD);
            localIntent.setClass(paramContext, CfpdActivity.class);
            break;
        default:
            localIntent = null;
            break;
        }
    } else if (paramInt1 == Global.NJZQ_ZXLP) {// 
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        switch (paramInt2) {
        case 0:
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_CPBD);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 1:
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_YWZJ);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 2:
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_PMHH);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 3:
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_TGLC);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 4:
            // localIntent.putExtra("pos", Global.NJZQ_ZXLP_ZJLX);
            // localIntent.setClass(paramContext, WebViewDisplay.class);
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_ZJLX);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 5:
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_GG);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        default:
            localIntent = null;
            break;
        }
    } else if (paramInt1 == Global.NJZQ_JFSC) {// ?
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // localIntent = genIsLoginIntent(Global.NJZQ_JFSC,
        // Global.NJZQ_JFSC, paramContext);
        localIntent.putExtra("pos", Global.NJZQ_JFSC);
        localIntent.setClass(paramContext, WebViewDisplay.class);
    } else if (paramInt1 == Global.NJZQ_ZSYYT) {// ?
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        switch (paramInt2) {
        case 0://
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_YYKH);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 1:
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_YYTGG);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 2:
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_YYWD);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 3:
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_YWZX);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 4:
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_TZZJY);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 5:
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_TJKH);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        default:
            localIntent = null;
            break;
        }
    }
    return localIntent;
}

From source file:com.manning.androidhacks.hack040.ImageDetailActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // Home or "up" navigation
        final Intent intent = new Intent(this, ImageGridActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);//w  w w .j ava2s  .  c om
        return true;
    case R.id.clear_cache:
        final ImageCache cache = mImageWorker.getImageCache();
        if (cache != null) {
            mImageWorker.getImageCache().clearCaches();
            // DiskLruCache.clearCache(this, ImageFetcher.HTTP_CACHE_DIR);
            Toast.makeText(this, R.string.clear_cache_complete, Toast.LENGTH_SHORT).show();
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.oakesville.mythling.MediaListActivity.java

@Override
public void sort() throws IOException, JSONException, ParseException {
    super.refresh();
    getAppSettings().setLastLoad(0);//from  w ww.  ja  v  a 2  s.  co  m
    SortType sortType = getAppSettings().getMediaSettings().getSortType();
    if (getMediaType() == MediaType.recordings
            && (sortType == SortType.byDate || sortType == SortType.byRating))
        setPath(""); // recordings list will be flattened
    Uri uri = new Uri.Builder().path(getPath()).build();
    Intent intent = new Intent(Intent.ACTION_VIEW, uri, this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    finish();
}

From source file:android.security.cts.BrowserTest.java

/**
 * Verify that no state is preserved across multiple intents sent
 * to the browser when we run out of usable browser tabs.  If such data is
 * preserved, then browser is vulnerable to a data stealing attack.
 *
 * In this test, we send 20 intents to the Android browser.  Each
 * intent sets the variable "document.b1" equal to 1.  If we are able
 * read document.b1 in subsequent invocations of the intent, then
 * we know state was preserved.  In that case, we send a message
 * to the local server, recording this fact.
 *
 * Our test fails if the local server ever receives an HTTP request.
 *
 * See http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2011-2357 for
 * vulnerability information this test case.
 *
 * See commits  096bae248453abe83cbb2e5a2c744bd62cdb620b and
 * afa4ab1e4c1d645e34bd408ce04cadfd2e5dae1e for patches for above vulnerability.
 *///from   w  w  w  . j  ava  2s .c om
public void testTabExhaustion() throws InterruptedException {
    List<Intent> intents = getAllJavascriptIntents();
    for (Intent i : intents) {
        i.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);

        /*
         * Send 20 intents.  20 is greater than the maximum number
         * of tabs allowed by the Android browser.
         */
        for (int j = 0; j < 20; j++) {
            mContext.startActivity(i);
        }

        /*
         * Wait 5 seconds for the browser to contact the server, but
         * fail fast if we detect the bug
         */
        for (int j = 0; j < 5; j++) {
            assertEquals(
                    "javascript handler preserves state across "
                            + "multiple intents. Vulnerable to CVE-2011-2357?",
                    0, mWebServer.getRequestCount());
            Thread.sleep(1000);
        }
    }
}

From source file:com.gotraveling.insthub.BeeFramework.service.PushMessageReceiver.java

@Override
public void onNotificationClicked(Context context, String title, String description,
        String customContentString) {
    String notifyString = " title=" + title + " description=" + description + " customContent="
            + customContentString;//w w w .  j a va  2  s . co  m
    //System.out.println("notifyString:"+notifyString);

    Intent responseIntent = null;
    responseIntent = new Intent(EcmobileMainActivity.ACTION_PUSHCLICK);
    responseIntent.setClass(context, EcmobileMainActivity.class);
    responseIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (customContentString != null) {
        responseIntent.putExtra(EcmobileMainActivity.CUSTOM_CONTENT, customContentString);
    }
    context.startActivity(responseIntent);
}