android.content.Intent#FLAG_ACTIVITY_BROUGHT_TO_FRONT源码实例Demo

下面列出了android.content.Intent#FLAG_ACTIVITY_BROUGHT_TO_FRONT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: a   文件: MyMainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {

    // 避免从桌面启动程序后,会重新实例化入口类的activity
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
        finish();
        return;
    }



    if (!MApplication.getInstance().isChangeTheme() && preferences.getBoolean(getString(R.string.pk_default_read), false)) {//第一次运行且设置了自动打开最近阅读
        MApplication.getInstance().setChangeTheme(false);
        startReadActivity();
    }
    MApplication.getInstance().setChangeTheme(false);

    // if (savedInstanceState != null) {
    //    resumed = savedInstanceState.getBoolean("resumed");
    //}
    group = preferences.getInt("bookshelfGroup", 0);
    //super.onCreate(savedInstanceState);
    super.onCreate(savedInstanceState);
}
 
源代码2 项目: Android-Application-ZJB   文件: SplashActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_splash);
    ButterKnife.inject(this);
    //1.解决安装后直接打开,home键切换到后台再启动重复出现闪屏页面的问题
    // http://stackoverflow.com/questions/2280361/app-always-starts-fresh-from-root-activity-instead-of-resuming-background-state
    if (!isTaskRoot()) {
        if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
            finish();
            return;
        }
    }
    //2.初始化
    initialize(this);
    //3.显示广告图片
    initView();
    //4.执行闪屏alpha动画
    animateSplash();
    //5.跳转
    jump();
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash_activity);
    Log.d("LinkedME", "origin onCreate: SplashActivity " + getIntent().getDataString());
    //处理首次安装点击打开切到后台,点击桌面图标再回来重启的问题及通过应用宝唤起在特定条件下重走逻辑的问题
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
        // Activity was brought to front and not created,
        // Thus finishing this will get us to the last viewed activity
        finish();
        return;
    }
    Intent intent = new Intent(SplashActivity.this, WelcomeActivity.class);
    startActivity(intent);

    finish();
}
 
源代码4 项目: CloudReader   文件: LoadingActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 后台返回时可能启动这个页面 http://blog.csdn.net/jianiuqi/article/details/54091181
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
        finish();
        return;
    }
    handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            startActivity(new Intent(LoadingActivity.this, MainActivity.class));
            overridePendingTransition(R.anim.screen_zoom_in, R.anim.screen_zoom_out);
            finish();
        }
    }, 200);
}
 
源代码5 项目: Lucid-Browser   文件: MainActivity.java
/**
 * When an app chooses to open a link with this browser (and the browser is already open), onNewIntent is called
 * @param intent provided by different app/activity
 */
@Override
   protected void onNewIntent(Intent intent) {
       super.onNewIntent(intent);
       Log.d("LB", "onNewIntent");
       if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) !=
               Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) {
       	drawerLayout.closeDrawers();
       }
       
       if (intent.getAction()!=null && (intent.getAction().equals(Intent.ACTION_WEB_SEARCH) ||intent.getAction().equals(Intent.ACTION_VIEW))){
       		if (intent.getDataString()!=null){
       			int tabNumber = intent.getIntExtra("tabNumber", -1); //used if intent is coming from Lucid Browser
       			
       			if (tabNumber!=-1 && tabNumber < webWindows.size()){
       				webWindows.get(tabNumber).loadUrl(intent.getDataString());
       			}else
       				tabNumber=-1;
       				
       			if (tabNumber==-1){
    	    		openURLInNewTab(intent.getDataString());
       			}
       			
       		}
       }
}
 
源代码6 项目: a   文件: MyMainActivity.java
@Override
    protected void onCreate(Bundle savedInstanceState) {
//
 	 //super.onCreate(savedInstanceState);
 
        // 避免从桌面启动程序后,会重新实例化入口类的activity
        if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
            finish();
            return;
        }



        if (!MApplication.getInstance().isChangeTheme() && preferences.getBoolean(getString(R.string.pk_default_read), false)) {//第一次运行且设置了自动打开最近阅读
            MApplication.getInstance().setChangeTheme(false);
            startReadActivity();
        }
        MApplication.getInstance().setChangeTheme(false);

        if (savedInstanceState != null) {
            resumed = savedInstanceState.getBoolean("resumed");
        }

        group = preferences.getInt("bookshelfGroup", 0);

        super.onCreate(savedInstanceState);
       
    }
 
源代码7 项目: sealrtc-android   文件: LauncherActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 首次启动 Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT 为 0,再次点击图标启动时就不为零了
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
        finish();
        return;
    }
    setContentView(R.layout.activity_launcher);
    ((TextView) findViewById(R.id.launcher_loading))
            .setTextColor(getResources().getColor(R.color.blink_launcher_grey));
    iv_logo = (ImageView) findViewById(R.id.iv_logo);
    if (iv_logo != null) {
        if (ServerUtils.usePrivateCloud()) {
            iv_logo.setImageResource(R.drawable.ic_launcher_privatecloud);
        } else {
            iv_logo.setImageResource(R.drawable.ic_launcher);
        }
    }

    SessionManager.getInstance().put(SettingActivity.IS_RONGRTC_CONNECTIONMODE, false);

    ServerUtils.APP_KEY = SessionManager.getInstance().getString(ServerUtils.APP_KEY_KEY);
    ServerUtils.NAV_SERVER = SessionManager.getInstance().getString(ServerUtils.NAV_SERVER_KEY);
    ServerUtils.APP_SECRET = SessionManager.getInstance().getString(ServerUtils.APP_SECRET_KEY);
    ServerUtils.API_SERVER = SessionManager.getInstance().getString(ServerUtils.API_SERVER_KEY);
    new Handler()
            .postDelayed(
                    new Runnable() {
                        @Override
                        public void run() {
                            skipToMainPage();
                        }
                    },
                    1000);
}
 
源代码8 项目: LaunchTime   文件: MainActivity.java
@Override
protected void onNewIntent(Intent intent) {
    if (mInitCalling) return;

    super.onNewIntent(intent);


    if (System.currentTimeMillis() - mPauseTime < 1000  && Intent.ACTION_MAIN.equals(intent.getAction())) {

        final boolean alreadyOnHome =
                ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
                        != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
        Log.d("LaunchTime", " new intent " + alreadyOnHome);
        if (alreadyOnHome && !mChildLock) {

            //mPrefs.edit().putString("category",getTopCategory()).apply();
            switchCategory(getTopCategory());
            // If we are on home screen, reset most things and go to top category.
            iconHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        mActionMenu.dismissAppinfo();
                        mSearchBox.setSearchText("");
                        mCategoriesScroller.smoothScrollTo(0, 0);
                        showButtonBar(false, true);
                        mIconSheetScroller.smoothScrollTo(0, 0);
                        mQuickRow.scrollToStart();
                        mIconSheetScroller.smoothScrollTo(0, 0);
                        mCategoriesScroller.smoothScrollTo(0, 0);
                    } catch (Exception e) {
                        Log.e(TAG, e.getMessage(), e);
                    }

                }
            }, 200);
        }

    }
}
 
源代码9 项目: LaunchEnr   文件: Launcher.java
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    boolean alreadyOnHome = mHasFocus && ((intent.getFlags() &
            Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
            != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);

    // Check this condition before handling isActionMain, as this will get reset.
    boolean shouldMoveToDefaultScreen = alreadyOnHome &&
            mState == State.WORKSPACE && AbstractFloatingView.getTopOpenView(this) == null;

    boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction());
    if (isActionMain) {
        if (mWorkspace == null) {
            // Can be cases where mWorkspace is null, this prevents a NPE
            return;
        }

        // TODO: Log this case.
        mWorkspace.exitWidgetResizeMode();

        // In all these cases, only animate if we're already on home
        AbstractFloatingView.closeAllOpenViews(this, alreadyOnHome);
        exitSpringLoadedDragMode();

        // If we are already on home, then just animate back to the workspace,
        // otherwise, just wait until onResume to set the state back to Workspace
        if (alreadyOnHome) {
            showWorkspace(true);
        } else {
            mOnResumeState = State.WORKSPACE;
        }

        closeKeyboard(this);

        // Reset the apps view
        if (!alreadyOnHome && mAppsView != null) {
            mAppsView.scrollToTop();
        }

        // Reset the widgets view
        if (!alreadyOnHome && mWidgetsView != null) {
            mWidgetsView.scrollToTop();
        }

        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onHomeIntent();
        }
    }
    PinItemDragListener.handleDragRequest(this, intent);

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onNewIntent(intent);
    }

    // Defer moving to the default screen until after we callback to the LauncherCallbacks
    // as slow logic in the callbacks eat into the time the scroller expects for the snapToPage
    // animation.
    if (isActionMain) {
        boolean callbackAllowsMoveToDefaultScreen = mLauncherCallbacks != null ?
                mLauncherCallbacks.shouldMoveToDefaultScreenOnHomeIntent() : true;
        if (shouldMoveToDefaultScreen && !mWorkspace.isTouchActive()
                && callbackAllowsMoveToDefaultScreen) {

            // We use this flag to suppress noisy callbacks above custom content state
            // from onResume.
            mMoveToDefaultScreenFromNewIntent = true;
            mWorkspace.post(new Runnable() {
                @Override
                public void run() {
                    if (mWorkspace != null) {
                        mWorkspace.moveToDefaultScreen(true);

                        if (GesturesUtils.isBoardEnabled(Launcher.this) && mBoard.getVisibility() == View.VISIBLE) {
                            GesturesUtils.openOrCloseBoard(Launcher.this, false, false);
                        }
                    }
                }
            });
        }
    }
}
 
源代码10 项目: TurboLauncher   文件: Launcher.java
@Override
protected void onNewIntent(Intent intent) {
	super.onNewIntent(intent);

	// Close the menu
	if (Intent.ACTION_MAIN.equals(intent.getAction())) {
		// also will cancel mWaitingForResult.
		closeSystemDialogs();

		if (mTransitionEffectDialog != null) {
			mTransitionEffectDialog.cancel();
		}

		final boolean alreadyOnHome = mHasFocus
				&& ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);

		if (mWorkspace == null) {
			// Can be cases where mWorkspace is null, this prevents a NPE
			return;
		}
		Folder openFolder = mWorkspace.getOpenFolder();
		// In all these cases, only animate if we're already on home
		mWorkspace.exitWidgetResizeMode();
		if (alreadyOnHome && mState == State.WORKSPACE
				&& !mWorkspace.isTouchActive() && openFolder == null
				&& shouldMoveToDefaultScreenOnHomeIntent()) {
			mWorkspace.moveToDefaultScreen(true);
		}

		closeFolder();
		exitSpringLoadedDragMode();

		// If we are already on home, then just animate back to the
		// workspace,
		// otherwise, just wait until onResume to set the state back to
		// Workspace
		if (alreadyOnHome) {
			showWorkspace(true);
		} else {
			mOnResumeState = State.WORKSPACE;
		}

		final View v = getWindow().peekDecorView();
		if (v != null && v.getWindowToken() != null) {
			InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
			imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
		}

		// Reset the apps customize page
		if (!alreadyOnHome && mAppsCustomizeLayout != null) {
			mAppsCustomizeLayout.reset();
		}

		onHomeIntent();
	}

}
 
 方法所在类
 同类方法