Example usage for android.content Intent ACTION_MAIN

List of usage examples for android.content Intent ACTION_MAIN

Introduction

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

Prototype

String ACTION_MAIN

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

Click Source Link

Document

Activity Action: Start as a main entry point, does not expect to receive data.

Usage

From source file:org.wso2.iot.agent.activities.AlreadyRegisteredActivity.java

/**
 * Load device home screen./* w  w  w  .j a v a 2 s.c o  m*/
 */

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void loadHomeScreen() {
    if (!devicePolicyManager.isProfileOwnerApp(getPackageName())) {
        finish();
        Intent i = new Intent();
        i.setAction(Intent.ACTION_MAIN);
        i.addCategory(Intent.CATEGORY_HOME);
        this.startActivity(i);
        super.onBackPressed();
    } else {
        Toast.makeText(this, "Press Home Button to exit.", Toast.LENGTH_SHORT).show();
    }
}

From source file:mgks.os.webview.MainActivity.java

public boolean url_actions(WebView view, String url) {
    boolean a = true;
    //Show toast error if not connected to the network
    if (!ASWP_OFFLINE && !DetectConnection.isInternetAvailable(MainActivity.this)) {
        Toast.makeText(getApplicationContext(), getString(R.string.check_connection), Toast.LENGTH_SHORT)
                .show();//  w  w  w .  j av a  2 s .  c  o m

        //Use this in a hyperlink to redirect back to default URL :: href="refresh:android"
    } else if (url.startsWith("refresh:")) {
        pull_fresh();

        //Use this in a hyperlink to launch default phone dialer for specific number :: href="tel:+919876543210"
    } else if (url.startsWith("tel:")) {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
        startActivity(intent);

        //Use this to open your apps page on google play store app :: href="rate:android"
    } else if (url.startsWith("rate:")) {
        final String app_package = getPackageName(); //requesting app package name from Context or Activity object
        try {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + app_package)));
        } catch (ActivityNotFoundException anfe) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://play.google.com/store/apps/details?id=" + app_package)));
        }

        //Sharing content from your webview to external apps :: href="share:URL" and remember to place the URL you want to share after share:___
    } else if (url.startsWith("share:")) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, view.getTitle());
        intent.putExtra(Intent.EXTRA_TEXT,
                view.getTitle() + "\nVisit: " + (Uri.parse(url).toString()).replace("share:", ""));
        startActivity(Intent.createChooser(intent, getString(R.string.share_w_friends)));

        //Use this in a hyperlink to exit your app :: href="exit:android"
    } else if (url.startsWith("exit:")) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);

        //Getting location for offline files
    } else if (url.startsWith("offloc:")) {
        String offloc = ASWV_URL + "?loc=" + get_location();
        aswm_view(offloc, false);
        Log.d("OFFLINE LOC REQ", offloc);

        //Opening external URLs in android default web browser
    } else if (ASWP_EXTURL && !aswm_host(url).equals(ASWV_HOST)) {
        aswm_view(url, true);
    } else {
        a = false;
    }
    return a;
}

From source file:org.mariotaku.twidere.provider.TwidereDataProvider.java

private void displayMentionsNotification(final Context context, final ContentValues[] values) {
    final Resources res = context.getResources();
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    final boolean display_screen_name = NAME_DISPLAY_OPTION_SCREEN_NAME
            .equals(mPreferences.getString(PREFERENCE_KEY_NAME_DISPLAY_OPTION, NAME_DISPLAY_OPTION_BOTH));
    final boolean display_hires_profile_image = res.getBoolean(R.bool.hires_profile_image);
    final Intent delete_intent = new Intent(BROADCAST_NOTIFICATION_CLEARED);
    final Bundle delete_extras = new Bundle();
    delete_extras.putInt(INTENT_KEY_NOTIFICATION_ID, NOTIFICATION_ID_MENTIONS);
    delete_intent.putExtras(delete_extras);
    final Intent content_intent;
    int notified_count = 0;
    // Add statuses that not filtered to list for future use.
    for (final ContentValues value : values) {
        final ParcelableStatus status = new ParcelableStatus(value);
        if (!isFiltered(mDatabase, status)) {
            mNewMentions.add(status);//  w  ww.  j  a v a 2 s.  c o m
            mNewMentionScreenNames.add(status.screen_name);
            mNewMentionAccounts.add(status.account_id);
            notified_count++;
        }
    }
    Collections.sort(mNewMentions);
    final int mentions_size = mNewMentions.size();
    if (notified_count == 0 || mentions_size == 0 || mNewMentionScreenNames.size() == 0)
        return;
    final String title;
    if (mentions_size > 1) {
        builder.setNumber(mentions_size);
    }
    final int screen_names_size = mNewMentionScreenNames.size();
    final ParcelableStatus status = mNewMentions.get(0);
    if (mentions_size == 1) {
        final Uri.Builder uri_builder = new Uri.Builder();
        uri_builder.scheme(SCHEME_TWIDERE);
        uri_builder.authority(AUTHORITY_STATUS);
        uri_builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(status.account_id));
        uri_builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(status.status_id));
        content_intent = new Intent(Intent.ACTION_VIEW, uri_builder.build());
    } else {
        content_intent = new Intent(context, HomeActivity.class);
        content_intent.setAction(Intent.ACTION_MAIN);
        content_intent.addCategory(Intent.CATEGORY_LAUNCHER);
        final Bundle content_extras = new Bundle();
        content_extras.putInt(INTENT_KEY_INITIAL_TAB, HomeActivity.TAB_POSITION_MENTIONS);
        content_intent.putExtras(content_extras);
    }
    if (screen_names_size > 1) {
        title = res.getString(R.string.notification_mention_multiple,
                display_screen_name ? "@" + status.screen_name : status.name, screen_names_size - 1);
    } else {
        title = res.getString(R.string.notification_mention,
                display_screen_name ? "@" + status.screen_name : status.name);
    }
    final String profile_image_url_string = status.profile_image_url_string;
    final File profile_image_file = mProfileImageLoader.getCachedImageFile(
            display_hires_profile_image ? getBiggerTwitterProfileImage(profile_image_url_string)
                    : profile_image_url_string);
    final int w = res.getDimensionPixelSize(R.dimen.notification_large_icon_width);
    final int h = res.getDimensionPixelSize(R.dimen.notification_large_icon_height);
    final Bitmap profile_image = profile_image_file != null && profile_image_file.isFile()
            ? BitmapFactory.decodeFile(profile_image_file.getPath())
            : null;
    final Bitmap profile_image_fallback = BitmapFactory.decodeResource(res,
            R.drawable.ic_profile_image_default);
    builder.setLargeIcon(Bitmap
            .createScaledBitmap(profile_image != null ? profile_image : profile_image_fallback, w, h, true));
    buildNotification(builder, title, title, status.text_plain, R.drawable.ic_stat_mention, null,
            content_intent, delete_intent);
    if (mentions_size > 1) {
        final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(builder);
        final int max = Math.min(4, mentions_size);
        for (int i = 0; i < max; i++) {
            final ParcelableStatus s = mNewMentions.get(i);
            final String name = display_screen_name ? "@" + s.screen_name : s.name;
            style.addLine(Html.fromHtml("<b>" + name + "</b>: "
                    + stripMentionText(s.text_plain, getAccountScreenName(context, s.account_id))));
        }
        if (max == 4 && mentions_size - max > 0) {
            style.addLine(context.getString(R.string.and_more, mentions_size - max));
        }
        final StringBuilder summary = new StringBuilder();
        final int accounts_count = mNewMentionAccounts.size();
        if (accounts_count > 0) {
            for (int i = 0; i < accounts_count; i++) {
                final String name = display_screen_name
                        ? "@" + getAccountScreenName(context, mNewMentionAccounts.get(i))
                        : getAccountName(context, mNewMentionAccounts.get(i));
                summary.append(name);
                if (i != accounts_count - 1) {
                    summary.append(", ");
                }
            }
            style.setSummaryText(summary);
        }
        mNotificationManager.notify(NOTIFICATION_ID_MENTIONS, style.build());
    } else {
        final Intent reply_intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        final List<String> mentions = new Extractor().extractMentionedScreennames(status.text_plain);
        mentions.remove(status.screen_name);
        mentions.add(0, status.screen_name);
        bundle.putInt(INTENT_KEY_NOTIFICATION_ID, NOTIFICATION_ID_MENTIONS);
        bundle.putStringArray(INTENT_KEY_MENTIONS, mentions.toArray(new String[mentions.size()]));
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id);
        bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, status.status_id);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, status.screen_name);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, status.name);
        reply_intent.putExtras(bundle);
        reply_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        builder.addAction(R.drawable.ic_menu_reply, context.getString(R.string.reply),
                PendingIntent.getActivity(context, 0, reply_intent, PendingIntent.FLAG_UPDATE_CURRENT));
        final NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle(builder);
        style.bigText(stripMentionText(status.text_plain, getAccountScreenName(context, status.account_id)));
        mNotificationManager.notify(NOTIFICATION_ID_MENTIONS, style.build());
    }
}

From source file:net.wequick.small.ApkBundleLauncher.java

@Override
public void setUp(Context context) {
    super.setUp(context);

    Field f;//w w w.ja  v a2 s . c om

    // AOP for pending intent
    try {
        f = TaskStackBuilder.class.getDeclaredField("IMPL");
        f.setAccessible(true);
        final Object impl = f.get(TaskStackBuilder.class);
        InvocationHandler aop = new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                Intent[] intents = (Intent[]) args[1];
                for (Intent intent : intents) {
                    sBundleInstrumentation.wrapIntent(intent);
                    intent.setAction(Intent.ACTION_MAIN);
                    intent.addCategory(Intent.CATEGORY_LAUNCHER);
                }
                return method.invoke(impl, args);
            }
        };
        Object newImpl = Proxy.newProxyInstance(context.getClassLoader(), impl.getClass().getInterfaces(), aop);
        f.set(TaskStackBuilder.class, newImpl);
    } catch (Exception ignored) {
        ignored.printStackTrace();
    }
}

From source file:org.wso2.cdm.agent.AuthenticationActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        Intent i = new Intent();
        i.setAction(Intent.ACTION_MAIN);
        i.addCategory(Intent.CATEGORY_HOME);
        this.startActivity(i);
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_HOME) {
        this.finish();
        return true;
    }// ww  w.  ja  va 2s  .c  o m
    return super.onKeyDown(keyCode, event);
}

From source file:com.nordicsemi.ImageTransferDemo.MainActivity.java

@Override
public void onBackPressed() {
    if (mState == UART_PROFILE_CONNECTED) {
        Intent startMain = new Intent(Intent.ACTION_MAIN);
        startMain.addCategory(Intent.CATEGORY_HOME);
        startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(startMain);/*w  ww .  ja v  a  2s  .  c  o m*/
        showMessage("nRFUART's running in background.\n             Disconnect to exit");
    } else {
        finish();
    }
}

From source file:com.nbplus.vbroadlauncher.fragment.LauncherFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_launcher, container, false);

    mMainViewLayout = (LinearLayout) v.findViewById(R.id.main_view_layout);

    // push agent ??.
    mPushServiceStatus = (ImageView) v.findViewById(R.id.ic_nav_wifi);
    if (((BaseActivity) getActivity()).isPushServiceConnected()) {
        mPushServiceStatus.setImageResource(R.drawable.ic_nav_wifi_on);
    } else {/*from  w w w  .j a  va 2 s.  co m*/
        mPushServiceStatus.setImageResource(R.drawable.ic_nav_wifi_off);
    }

    mVillageName = (TextView) v.findViewById(R.id.launcher_village_name);
    mVillageName.setText(LauncherSettings.getInstance(getActivity()).getVillageName());

    mApplicationsView = (LinearLayout) v.findViewById(R.id.ic_nav_apps);
    mApplicationsView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(getActivity(), ShowApplicationActivity.class);
            startActivity(intent);
            getActivity().overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
        }
    });
    mServiceTreeMap = (LinearLayout) v.findViewById(R.id.ic_nav_show_map);
    mServiceTreeMap.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (!NetworkUtils.isConnected(getActivity())) {
                ((BaseActivity) getActivity()).showNetworkConnectionAlertDialog();
                return;
            }
            Intent intent = new Intent(getActivity(), BroadcastWebViewActivity.class);

            ShortcutData data = new ShortcutData(Constants.SHORTCUT_TYPE_WEB_DOCUMENT_SERVER,
                    R.string.btn_show_map, getActivity().getResources().getString(R.string.addr_show_map),
                    R.drawable.ic_menu_04, R.drawable.ic_menu_shortcut_02_selector, 0, null);

            VBroadcastServer serverInfo = LauncherSettings.getInstance(getActivity()).getServerInformation();
            data.setDomain(serverInfo.getDocServer());

            intent.putExtra(Constants.EXTRA_NAME_SHORTCUT_DATA, data);
            startActivity(intent);
        }
    });
    mOutdoorMode = (LinearLayout) v.findViewById(R.id.ic_nav_outdoor);
    mOutdoorText = (TextView) v.findViewById(R.id.tv_outdoor);
    if (LauncherSettings.getInstance(getActivity()).isOutdoorMode()) {
        mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_on));
        mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_on, 0, 0, 0);
    } else {
        mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_off));
        mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_off, 0, 0, 0);
    }
    mOutdoorMode.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast toast;

            boolean mode = false;
            if (LauncherSettings.getInstance(getActivity()).isOutdoorMode()) {
                LauncherSettings.getInstance(getActivity()).setIsOutdoorMode(false);
                mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_off, 0, 0, 0);
                mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_off));

                toast = Toast.makeText(getActivity(), R.string.outdoor_mode_off, Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
                toast.show();
            } else {
                mode = true;
                LauncherSettings.getInstance(getActivity()).setIsOutdoorMode(true);
                mOutdoorText.setTextColor(getResources().getColor(R.color.btn_color_absentia_on));
                mOutdoorText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_nav_absentia_on, 0, 0, 0);

                toast = Toast.makeText(getActivity(), R.string.outdoor_mode_on, Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
                toast.show();
            }

            HomeLauncherApplication application = (HomeLauncherApplication) getActivity()
                    .getApplicationContext();
            if (application != null) {
                application.outdoorModeChanged(mode);
            }
        }
    });
    // ?? ?
    mIoTDataSync = (LinearLayout) v.findViewById(R.id.ic_iot_data_sync);
    mIoTDataSyncText = (TextView) v.findViewById(R.id.tv_iot_data_sync);
    mIoTDataSync.setOnClickListener(mIoTSyncClickListener);
    mIoTDataSync.setClickable(true);
    mIoTDataSync.setEnabled(true);

    mTextClock = (TextClock) v.findViewById(R.id.text_clock);
    if (mTextClock != null) {
        mTextClock.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Intent intent = new Intent(Intent.ACTION_MAIN);
                    intent.addCategory(Intent.CATEGORY_APP_CALENDAR);
                    startActivity(intent);
                    getActivity().overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                } catch (ActivityNotFoundException e) {
                    e.printStackTrace();
                    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
                    alert.setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent i = new Intent(
                                    android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
                            i.addCategory(Intent.CATEGORY_DEFAULT);
                            startActivity(i);
                        }
                    });
                    alert.setMessage(R.string.alert_calendar_not_found);
                    alert.show();
                }
            }
        });
    }
    mWeatherView = (WeatherView) v.findViewById(R.id.weather_view);
    mMainViewLeftPanel = (LinearLayout) v.findViewById(R.id.main_view_left_panel);
    mMainViewRightPanel = (LinearLayout) v.findViewById(R.id.main_view_right_panel);

    LayoutInflater layoutInflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // add main shortcut.
    ArrayList<ShortcutData> mainShortcutDatas = LauncherSettings.getInstance(getActivity())
            .getLauncherMainShortcuts();
    mMainShortcutGridLayout = (GridLayout) v.findViewById(R.id.main_shortcut_grid);
    float dp;// = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_width);
    //        float widthPx = DisplayUtils.pxFromDp(getActivity(), dp);
    //
    //        dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_height);
    //        float heightPx = DisplayUtils.pxFromDp(getActivity(), dp);

    dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_main_shortcut_font_size);
    float mainShortcutFontPx = DisplayUtils.pxFromDp(getActivity(), dp);
    for (int i = 0; i < mMainShortcutGridLayout.getColumnCount(); i++) {
        /**
         * right shortcut panel
         */
        ShortcutData data = mainShortcutDatas.get(i);
        FrameLayout btnLayout = (FrameLayout) layoutInflater.inflate(R.layout.launcher_menu_top_item,
                mMainShortcutGridLayout, false);//new Button(getActivity());
        mMainShortcutGridLayout.addView(btnLayout);
        if (data.getPushType() != null && data.getPushType().length > 0) {
            data.setLauncherButton(btnLayout);
            mPushNotifiableShorcuts.add(data);
        }

        btnLayout.setBackgroundResource(data.getIconBackResId());

        //            GridLayout.LayoutParams lp = (GridLayout.LayoutParams)btnLayout.getLayoutParams();
        //            lp.width = (int)widthPx;
        //            lp.height = (int)heightPx;
        //            btnLayout.setLayoutParams(lp);

        TextView label = (TextView) btnLayout.findViewById(R.id.menu_item_label);
        label.setText(data.getName());
        label.setTextSize(TypedValue.COMPLEX_UNIT_PX, mainShortcutFontPx);
        label.setTextColor(getResources().getColor(R.color.white));
        label.setTypeface(null, Typeface.BOLD);
        label.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);

        ImageView icon = (ImageView) btnLayout.findViewById(R.id.menu_item_image);
        icon.setImageResource(data.getIconResId());

        btnLayout.setTag(data);
        btnLayout.setOnClickListener(this);
    }

    // add other shortcuts.
    mShorcutGridLayout = (GridLayout) v.findViewById(R.id.shortcut_grid);
    ArrayList<ShortcutData> shortcutDatas = LauncherSettings.getInstance(getActivity()).getLauncherShortcuts();
    int columnNum = mShorcutGridLayout.getColumnCount();
    final int MAX_ROW_NUM = 3;

    int shortcutNum = shortcutDatas.size() > (columnNum * MAX_ROW_NUM) ? (columnNum * MAX_ROW_NUM)
            : shortcutDatas.size();
    dp = DisplayUtils.getDimension(getActivity(), R.dimen.launcher_ic_menu_shortcut_font_size);
    float btnFontPx = DisplayUtils.pxFromDp(getActivity(), dp);

    for (int i = 0; i < shortcutNum; i++) {
        /**
         * right shortcut panel
         */
        ShortcutData data = shortcutDatas.get(i);
        FrameLayout btnLayout = (FrameLayout) layoutInflater.inflate(R.layout.launcher_menu_item,
                mShorcutGridLayout, false);//new Button(getActivity());
        mShorcutGridLayout.addView(btnLayout);
        if (data.getPushType() != null && data.getPushType().length > 0) {
            data.setLauncherButton(btnLayout);
            mPushNotifiableShorcuts.add(data);
        }

        btnLayout.setBackgroundResource(data.getIconBackResId());

        TextView label = (TextView) btnLayout.findViewById(R.id.menu_item_label);
        label.setText(data.getName());
        label.setTextSize(TypedValue.COMPLEX_UNIT_PX, btnFontPx);
        label.setTextColor(getResources().getColor(R.color.white));
        label.setTypeface(null, Typeface.BOLD);
        label.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);

        ImageView icon = (ImageView) btnLayout.findViewById(R.id.menu_item_image);
        icon.setImageResource(data.getIconResId());

        btnLayout.setTag(data);
        btnLayout.setOnClickListener(this);
    }

    setContentViewByOrientation();

    return v;
}

From source file:com.example.alyshia.customsimplelauncher.MainActivity.java

private void initUI() {

    mSpaceFrag.add(new AppsGridFragment());
    mSpaceFrag.add(new AppsGridFragment());

    mPagerAdapter = new workSpacePagerAdapter(getSupportFragmentManager());
    workSpaces.setAdapter(mPagerAdapter);

    Intent intent_ = new Intent(Intent.ACTION_MAIN, null);
    intent_.addCategory(Intent.CATEGORY_LAUNCHER);
    mPM = getPackageManager();/*from   w  w w  . ja  v  a 2  s. c om*/
    apps = mPM.queryIntentActivities(intent_, 0);
    apps_package = new ArrayList<>();
    optionalApps = new ArrayList<>();
    knoxappPrefs = getSharedPreferences(KnoxConstants.PREFS_KNOX, MODE_PRIVATE);
    knoxappPrefsEditor = knoxappPrefs.edit();

}

From source file:com.linkbubble.util.Util.java

public static List<ResolveInfo> getLauncherAppForApplicationIds(Context context, String applicationId) {
    Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER)
            .setPackage(applicationId);//  w ww .jav  a  2  s  .co  m
    List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(intent, 0);
    if (resolveInfos != null && resolveInfos.size() > 0) {
        return resolveInfos;
    }
    return null;
}

From source file:info.papdt.blacklight.ui.main.MainActivity.java

@Binded
public void settings() {
    Intent i = new Intent();
    i.setAction(Intent.ACTION_MAIN);
    i.setClass(this, SettingsActivity.class);
    startActivity(i);//www .j  a  va 2  s  .c o  m
    openOrCloseDrawer();
}