List of usage examples for android.content Intent CATEGORY_HOME
String CATEGORY_HOME
To view the source code for android.content Intent CATEGORY_HOME.
Click Source Link
From source file:org.jonblack.bluetrack.activities.MainActivity.java
/** * Do not let the back key call finish on our activity. *///from ww w. j a va2 s. c o m @Override public void onBackPressed() { Log.d(TAG, "onBackPressed Called"); Intent setIntent = new Intent(Intent.ACTION_MAIN); setIntent.addCategory(Intent.CATEGORY_HOME); setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(setIntent); }
From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java
private List<String> getHomes() { List<String> names = new ArrayList<String>(); try {//from w w w . j a v a 2s. c o m PackageManager packageManager = mActivity.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo ri : resolveInfo) { names.add(ri.activityInfo.packageName); System.out.println(ri.activityInfo.packageName); } } catch (Exception e) { } return names; }
From source file:ie.ucd.www.bee.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: Log.e("KEY_EVENT", "KeyEvent.KEYCODE_BACK"); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);/*w ww.j a v a2 s .c om*/ break; } return super.onKeyDown(keyCode, event); }
From source file:io.github.runassudo.ptoffline.fragments.SettingsFragment.java
@Override public void onCreatePreferences(Bundle savedInstanceState, String s) { // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); TransportNetwork network = Preferences.getTransportNetwork(getActivity()); // Fill in current home location if available network_pref = findPreference("pref_key_network"); if (network != null) network_pref.setSummary(network.getName()); network_pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override// w ww . j a v a 2 s . c o m public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(getActivity(), PickNetworkProviderActivity.class); // View view = preference.getView(null, null); View view = getView(); if (view != null) view = view.findFocus(); ActivityOptionsCompat options = ActivityOptionsCompat.makeScaleUpAnimation(view, (int) view.getX(), (int) view.getY(), 0, 0); ActivityCompat.startActivityForResult(getActivity(), intent, MainActivity.CHANGED_NETWORK_PROVIDER, options.toBundle()); return true; } }); home = findPreference("pref_key_home"); home.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // show home picker dialog HomePickerDialogFragment setHomeFragment = HomePickerDialogFragment.newInstance(); setHomeFragment.setOnHomeChangedListener(SettingsFragment.this); FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); setHomeFragment.show(ft, HomePickerDialogFragment.TAG); return true; } }); // Fill in current home location if available if (network != null) setHome(null); quickhome = findPreference("pref_key_create_quickhome_shortcut"); quickhome.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // create launcher shortcut Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, TransportrUtils.getShortcutIntent(getContext())); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.widget_name_quickhome)); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getContext(), R.drawable.ic_quickhome_widget)); addIntent.putExtra("duplicate", false); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getContext().sendBroadcast(addIntent); // switch to home-screen to let the user see the new shortcut Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startMain); return true; } }); }
From source file:de.grobox.liberario.settings.SettingsFragment.java
@Override public void onCreatePreferences(Bundle savedInstanceState, String s) { // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); TransportNetwork network = Preferences.getTransportNetwork(getActivity()); // Fill in current home location if available network_pref = findPreference("pref_key_network"); if (network != null) network_pref.setSummary(network.getName(getContext())); network_pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override/*from w ww . j ava2s . c o m*/ public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(getActivity(), PickTransportNetworkActivity.class); View view = getView(); if (view != null) view = view.findFocus(); ActivityOptionsCompat options = ActivityOptionsCompat.makeScaleUpAnimation(view, (int) view.getX(), (int) view.getY(), 0, 0); ActivityCompat.startActivityForResult(getActivity(), intent, REQUEST_NETWORK_PROVIDER_CHANGE, options.toBundle()); return true; } }); // TODO remove from here home = findPreference("pref_key_home"); home.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // show home picker dialog HomePickerDialogFragment setHomeFragment = HomePickerDialogFragment.newInstance(); FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); setHomeFragment.show(ft, HomePickerDialogFragment.TAG); return true; } }); // Fill in current home location if available if (network != null) setHome(null); quickhome = findPreference("pref_key_create_quickhome_shortcut"); quickhome.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // create launcher shortcut Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, TransportrUtils.getShortcutIntent(getContext())); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.widget_name_quickhome)); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getContext(), R.drawable.ic_quickhome_widget)); addIntent.putExtra("duplicate", false); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getContext().sendBroadcast(addIntent); // switch to home-screen to let the user see the new shortcut Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startMain); return true; } }); }
From source file:com.gigathinking.simpleapplock.ResetUnlockMethod.java
@Override public void onBackPressed() { finish();/* www. ja v a2s . co 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.wrmndfzzy.atomize.intro.IntroActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { switch (requestCode) { case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: { // If request is cancelled, the result arrays are empty. if (grantResults.length <= 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) { // permission denied, boo! Disable the // functionality that depends on this permission. Toast.makeText(IntroActivity.this, "Read permissions are required to run this app.", Toast.LENGTH_LONG).show(); Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(homeIntent);//from w w w .j a v a 2s . c om } else { Toast.makeText(IntroActivity.this, "Read permissions granted!", Toast.LENGTH_SHORT).show(); } break; } case MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: { // If request is cancelled, the result arrays are empty. if (grantResults.length <= 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) { // permission denied, boo! Disable the // functionality that depends on this permission. Toast.makeText(IntroActivity.this, "Write permissions are required to run this app.", Toast.LENGTH_LONG).show(); Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(homeIntent); } else { Toast.makeText(IntroActivity.this, "Write permissions granted!", Toast.LENGTH_SHORT).show(); } break; } } }
From source file:com.wso2.mobile.mdm.DisplayDeviceInfoActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && FROM_ACTIVITY != null && FROM_ACTIVITY.equals(AlreadyRegisteredActivity.class.getSimpleName())) { Intent intent = new Intent(DisplayDeviceInfoActivity.this, AlreadyRegisteredActivity.class); intent.putExtra(getResources().getString(R.string.intent_extra_from_activity), DisplayDeviceInfoActivity.class.getSimpleName()); intent.putExtra(getResources().getString(R.string.intent_extra_regid), REG_ID); startActivity(intent);/*w w w.jav a 2 s. c o m*/ return true; } else if (keyCode == KeyEvent.KEYCODE_BACK) { Intent i = new Intent(); i.setAction(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_HOME); this.startActivity(i); this.finish(); return true; } return super.onKeyDown(keyCode, event); }
From source file:de.hshannover.f4.trust.ironcontrol.view.SearchFragmentActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_settings: startActivity(new Intent(getBaseContext(), SettingsActivity.class)); return true; case R.id.menu_exit: Intent home = new Intent(Intent.ACTION_MAIN); home.addCategory(Intent.CATEGORY_HOME); home.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(home);//from w ww . j av a 2 s . c om return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.greatnowhere.radar.MainRadarActivity.java
public void goHome() { Intent setIntent = new Intent(Intent.ACTION_MAIN); setIntent.addCategory(Intent.CATEGORY_HOME); setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(setIntent);//from w ww . j a v a 2s. c om }