Example usage for android.content Intent CATEGORY_HOME

List of usage examples for android.content Intent CATEGORY_HOME

Introduction

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

Prototype

String CATEGORY_HOME

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

Click Source Link

Document

This is the home activity, that is the first activity that is displayed when the device boots.

Usage

From source file:com.oo58.game.texaspoker.AppActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //         this.getWindow().setFlags(FLAG_HOMEKEY_DISPATCHED, FLAG_HOMEKEY_DISPATCHED);//
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    mContext = AppActivity.this;

    try {//from   w  w w  . j a v a 2s  .co  m
        ApplicationInfo appInfo = this.getPackageManager().getApplicationInfo(getPackageName(),
                PackageManager.GET_META_DATA);
        String msg = appInfo.metaData.getString("data_Name");

        //         int channelid = Integer.parseInt(msg) ;
        //         
        //         System.out.println(channelid);

    } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    mAct = this;
    allContext = this.getApplicationContext();
    mTencent = Tencent.createInstance("1104823392", getApplicationContext());
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "MyLock");
    mWakeLock.acquire();

    MobclickAgent.setDebugMode(false);
    MobclickAgent.updateOnlineConfig(this);
    AnalyticsConfig.enableEncrypt(true);

    checkUpdate();

    PackageManager pm2 = getPackageManager();
    homeInfo = pm2.resolveActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), 0);

    mNetChecker.initAndRegListener(mContext);

    mWXPay.init(this);

    MobClickCppHelper.init(this);

    //      // logcatdebug
    //       XGPushConfig.enableDebug(this, true);
    //      // registerPush(getApplicationContext(), XGIOperateCallback)callback
    //      // registerPush(getApplicationContext(),account)
    //      // 
    //      // ApplicationContext
    //      Context context = getApplicationContext();
    //      XGPushManager.registerPush(context);    
    //       
    //      // 2.362
    //      Intent service = new Intent(context, XGPushService.class);
    //      context.startService(service);

    // API
    // registerPush(context,account)registerPush(context,account, XGIOperateCallback)accountAPPqqopenid
    // registerPush(context,"*")account="*"
    // unregisterPush(context)
    // setTag(context, tagName)
    // deleteTag(context, tagName)

    updateListViewReceiver = new MsgReceiver();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction("com.oo58.game.texaspoker.activity.UPDATE_LISTVIEW");
    registerReceiver(updateListViewReceiver, intentFilter);

    XGPushManager.registerPush(getApplicationContext(), new XGIOperateCallback() {
        @Override
        public void onSuccess(Object data, int flag) {
            //                  Log.w(Constants.LogTag,
            //                        "+++ register push sucess. token:" + data);

        }

        @Override
        public void onFail(Object data, int errCode, String msg) {
            //                  Log.w(Constants.LogTag,
            //                        "+++ register push fail. token:" + data
            //                              + ", errCode:" + errCode + ",msg:"
            //                              + msg);

        }
    });

    //javajosnC++demo
    /*      JSONObject jsonObj = new JSONObject();  
            try {
             jsonObj.put("Int_att",25);
               jsonObj.put("String_att","str");//string  
               jsonObj.put("Double_att",12.25);//double  
               jsonObj.put("Boolean_att",true);//boolean  
          } catch (JSONException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
          }//int  
            
            PushJson(jsonObj.toString()) ;*/

}

From source file:com.gigathinking.simpleapplock.ResetUnlockMethod.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == android.R.id.home) {
        finish();/*from   w  w w . j  a  v a  2 s  .co  m*/
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:library.artaris.cn.library.utils.SystemUtils.java

/**
 * Home/*from   ww w  . ja  v  a 2  s  .co  m*/
 * @param context
 */
public static void goHome(Context context) {
    Intent mHomeIntent = new Intent(Intent.ACTION_MAIN);
    mHomeIntent.addCategory(Intent.CATEGORY_HOME);
    mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    context.startActivity(mHomeIntent);
}

From source file:com.thelastcrusade.soundstream.CoreActivity.java

@Override
public void onBackPressed() {
    //if we are in the connect fragment or the menu is open, 
    //back out of the app by pulling up the home screen
    if (getTitle().equals(getString(R.string.select)) || getSlidingMenu().isMenuShowing()) {
        Intent startMain = new Intent(Intent.ACTION_MAIN);
        startMain.addCategory(Intent.CATEGORY_HOME);
        startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(startMain);//  ww w.  ja  v  a2  s  . com
    }
    //otherwise, open the menu
    else {
        showMenu();
    }

}

From source file:com.dcs.fakecurrencydetector.MainActivity.java

public void AppExit() {

    this.finish();
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);/*w  w  w .java2  s . c  o  m*/

    /*int pid = android.os.Process.myPid();=====> use this if you want to kill your activity. But its not a good one to do.
    android.os.Process.killProcess(pid);*/

}

From source file:com.example.administrator.winsoftsalesproject.activity.NavHomeActivity.java

public void exitDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Do You Want To Exit?").setTitle("Exit App");

    builder.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {
        @Override//  ww w .j a v a  2 s.com
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            Intent homeIntent = new Intent(Intent.ACTION_MAIN);
            homeIntent.addCategory(Intent.CATEGORY_HOME);
            homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            sessionManger.logoutUser();
            NavHomeActivity.this.finish();
            startActivity(homeIntent);
        }
    });
    AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:com.farmerbb.taskbar.fragment.FreeformModeFragment.java

@TargetApi(Build.VERSION_CODES.N)
@Override//  www.  j  av a  2  s  . c o  m
public boolean onPreferenceClick(final Preference p) {
    final SharedPreferences pref = U.getSharedPreferences(getActivity());

    switch (p.getKey()) {
    case "freeform_hack":
        if (((CheckBoxPreference) p).isChecked()) {
            if (!U.hasFreeformSupport(getActivity())) {
                ((CheckBoxPreference) p).setChecked(false);

                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle(R.string.freeform_dialog_title).setMessage(R.string.freeform_dialog_message)
                        .setPositiveButton(R.string.action_developer_options, (dialogInterface, i) -> {
                            showReminderToast = true;

                            Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
                            try {
                                startActivity(intent);
                                U.showToastLong(getActivity(), R.string.enable_force_activities_resizable);
                            } catch (ActivityNotFoundException e) {
                                intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS);
                                try {
                                    startActivity(intent);
                                    U.showToastLong(getActivity(), R.string.enable_developer_options);
                                } catch (ActivityNotFoundException e2) {
                                    /* Gracefully fail */ }
                            }
                        });

                AlertDialog dialog = builder.create();
                dialog.show();
                dialog.setCancelable(false);
            }

            if (pref.getBoolean("taskbar_active", false) && getActivity().isInMultiWindowMode()
                    && !FreeformHackHelper.getInstance().isFreeformHackActive()) {
                U.startFreeformHack(getActivity(), false, false);
            }
        } else {
            LocalBroadcastManager.getInstance(getActivity())
                    .sendBroadcast(new Intent("com.farmerbb.taskbar.FINISH_FREEFORM_ACTIVITY"));
            LocalBroadcastManager.getInstance(getActivity())
                    .sendBroadcast(new Intent("com.farmerbb.taskbar.FORCE_TASKBAR_RESTART"));
        }

        break;
    case "freeform_mode_help":
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setView(View.inflate(getActivity(), R.layout.freeform_help_dialog, null))
                .setTitle(R.string.freeform_help_dialog_title).setPositiveButton(R.string.action_close, null);

        AlertDialog dialog = builder.create();
        dialog.show();
        break;
    case "add_shortcut":
        Intent intent = U.getShortcutIntent(getActivity());
        intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
        intent.putExtra("duplicate", false);

        Intent homeIntent = new Intent(Intent.ACTION_MAIN);
        homeIntent.addCategory(Intent.CATEGORY_HOME);
        ResolveInfo defaultLauncher = getActivity().getPackageManager().resolveActivity(homeIntent,
                PackageManager.MATCH_DEFAULT_ONLY);

        intent.setPackage(defaultLauncher.activityInfo.packageName);
        getActivity().sendBroadcast(intent);

        U.showToast(getActivity(), R.string.shortcut_created);
        break;
    case "window_size":
        if (U.isOPreview()) {
            U.showToast(getActivity(), R.string.window_sizes_not_available);
        }

        break;
    }

    return true;
}

From source file:com.nextgis.ngm_clink_monitoring.activities.MainActivity.java

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

    if (getIntent().getBooleanExtra(FoclConstants.NO_SDCARD, false)) {

        YesNoDialog dialog = new YesNoDialog();
        dialog.setCancelable(false);// w ww .  jav  a 2 s . c  o m
        dialog.setKeepInstance(true).setIcon(R.drawable.ic_action_warning).setTitle(R.string.warning)
                .setMessage(getString(R.string.no_sdcard_exit_app)).setPositiveText(R.string.ok)
                .setOnPositiveClickedListener(new YesNoDialog.OnPositiveClickedListener() {
                    @Override
                    public void onPositiveClicked() {
                        // show Home screen
                        Intent intent = new Intent(Intent.ACTION_MAIN);
                        intent.addCategory(Intent.CATEGORY_HOME);
                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        startActivity(intent);

                        System.exit(0);
                    }
                }).show(getSupportFragmentManager(), FoclConstants.FRAGMENT_YES_NO_DIALOG + "NoSdCard");
        return;
    }

    final GISApplication app = (GISApplication) getApplication();

    mGpsEventSource = app.getGpsEventSource();
    if (null != mGpsEventSource) {
        mGpsEventSource.addListener(this);
    }

    // initialize the default settings
    PreferenceManager.setDefaultValues(this, R.xml.preferences_general, false);

    mSyncStatusObserver = new SyncStatusObserver() {
        @Override
        public void onStatusChanged(int which) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Account account = app.getAccount();

                    if (null != account) {
                        mIsSyncing = AccountUtil.isSyncActive(account, FoclSettingsConstantsUI.AUTHORITY);
                        switchMenuView();
                    }
                }
            });
        }
    };

    setContentView(R.layout.activity_main);

    mMainToolbar = (Toolbar) findViewById(R.id.main_toolbar_cl);
    mMainToolbar.setTitle(""); // needed for screen rotation
    mMainToolbar.getBackground().setAlpha(255);
    setSupportActionBar(mMainToolbar);

    mBottomToolbar = (Toolbar) findViewById(R.id.bottom_toolbar_cl);
    mBottomToolbar.setContentInsetsAbsolute(0, 0);
    mBottomToolbar.getBackground().setAlpha(255);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        // Inflate a custom action bar that contains the "done" button
        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View customActionBarView = inflater.inflate(R.layout.editor_custom_action_bar, null);

        mCustomToolbarTitle = (TextView) customActionBarView.findViewById(R.id.custom_toolbar_title);
        mCustomToolbarButton = (TextView) customActionBarView.findViewById(R.id.custom_toolbar_button);
        mCustomToolbarImage = (ImageView) customActionBarView.findViewById(R.id.custom_toolbar_image);

        actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
        actionBar.setCustomView(customActionBarView);
    }

    // TODO: remove it
    //        FragmentManager fm = getSupportFragmentManager();
    //        mStatusBarFragment =
    //                (StatusBarFragment) fm.findFragmentByTag(FoclConstants.FRAGMENT_STATUS_BAR);
    //        if (null == mStatusBarFragment) {
    //            mStatusBarFragment = new StatusBarFragment();
    //            FragmentTransaction ft = fm.beginTransaction();
    //            ft.replace(
    //                    R.id.status_bar_fragment, mStatusBarFragment,
    //                    FoclConstants.FRAGMENT_STATUS_BAR);
    //            ft.hide(mStatusBarFragment);
    //            ft.commit();
    //        }

    if (null == savedInstanceState) {
        if (!app.hasAccount()) {
            mViewState = VIEW_STATE_LOGIN;
        } else if (null == app.getFoclProject()) {
            mViewState = VIEW_STATE_1ST_SYNC;
        } else {
            mViewState = VIEW_STATE_OBJECTS;
        }
    } else {
        if (savedInstanceState.containsKey(FoclConstants.VIEW_STATE)) {
            mViewState = savedInstanceState.getInt(FoclConstants.VIEW_STATE);
        }
    }

    setActivityView();

    // workaround for YesNoDialog destroying by the screen rotation
    FragmentManager fm = getSupportFragmentManager();
    Fragment fr = fm.findFragmentByTag(FoclConstants.FRAGMENT_YES_NO_DIALOG + "CancelObjectCreating");
    if (null != fr) {
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.remove(fr);
        ft.commit();
    }
}

From source file:com.cryart.sabbathschool.ui.activity.SSMainActivity.java

@Override
public void onBackPressed() {
    if (_SSDrawerLayout.isDrawerOpen(Gravity.START)) {
        _SSDrawerLayout.closeDrawer(Gravity.START);
    } else {/*from  w  ww.  j av  a2 s .  c  o  m*/
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }
}

From source file:com.wifi.brainbreaker.mydemo.spydroid.ui.SpydroidActivity.java

@Override
public void onBackPressed() {
    Intent setIntent = new Intent(Intent.ACTION_MAIN);
    setIntent.addCategory(Intent.CATEGORY_HOME);
    setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(setIntent);/*from  w w w  .  j  a  va2 s .com*/
}