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:at.jclehner.rxdroid.SplashScreenActivity.java

@Override
protected void onResume() {
    //registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_MAIN));
    RxDroid.getLocalBroadcastManager().registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_MAIN));
    loadDatabaseAndLaunchMainActivity();
    super.onResume();
}

From source file:at.jclehner.rxdroid.SplashScreenActivity.java

public static void setStatusMessage(int msgResId) {
    final Context context = RxDroid.getContext();
    final Intent intent = new Intent(context, DatabaseStatusReceiver.class);
    intent.setAction(Intent.ACTION_MAIN);
    intent.putExtra(DatabaseStatusReceiver.EXTRA_MESSAGE, msgResId);

    LocalBroadcastManager bm = RxDroid.getLocalBroadcastManager();
    bm.sendBroadcast(intent);/*from www. j  a v a 2 s.  c  o m*/
}

From source file:com.launcher.silverfish.launcher.appdrawer.AppDrawerTabFragment.java

/**
 * Loads apps from the database/*from   w w  w .ja v  a2  s. c o  m*/
 */
private void loadApps() {

    Intent i = new Intent(Intent.ACTION_MAIN, null);
    i.addCategory(Intent.CATEGORY_LAUNCHER);

    switch ((int) tabId) {
    case 1:
        // Tab 1 is a special tab and includes all except for the ones in other tabs
        // Retrieve all installed apps on the device
        List<ResolveInfo> availableActivities = mPacMan.queryIntentActivities(i, 0);

        // And only add those that are not in the database
        for (int j = 0; j < availableActivities.size(); j++) {
            ResolveInfo ri = availableActivities.get(j);

            if (sqlHelper.containsApp(ri.activityInfo.packageName))
                continue;

            AppDetail app = new AppDetail();
            app.label = ri.loadLabel(mPacMan);
            app.packageName = ri.activityInfo.packageName;

            // Load the icon later in an async task.
            app.icon = null;

            appsList.add(app);
        }
        break;
    default:
        // All other tabs just query the apps from the database
        List<AppTable> apps = sqlHelper.getAppsForTab(tabId);
        for (AppTable app : apps) {

            boolean success = addAppToList(app.getPackageName());
            // If the app could not be added then it was probably uninstalled,
            // so we have to remove it from the database
            if (!success) {
                Log.d("DB", "Removing app " + app.getPackageName() + " from db");
                sqlHelper.removeAppFromTab(app.getPackageName(), this.tabId);
            }
        }

        // show the empty category notice if this tab is empty
        if (apps.size() == 0) {
            showEmptyCategoryNotice();
        }
    }
}

From source file:org.deviceconnect.android.deviceplugin.hvcc2w.setting.fragment.HVCC2WAccountRegisterFragment.java

/** Execute Signup.*/
private void exeSignup(final String email) {
    HVCManager.INSTANCE.signup(email, new HVCManager.ResponseListener() {
        @Override//from ww w.  jav  a2s  . com
        public void onReceived(String json) {
            try {
                if (json == null) {
                    HVCC2WDialogFragment.showAlert(getActivity(), getString(R.string.hw_name),
                            getString(R.string.c2w_setting_error_4), null);
                    return;
                }
                JSONObject jsonObject = new JSONObject(json);
                JSONObject result = jsonObject.getJSONObject("result");
                String code = result.getString("code");
                String msg = result.getString("msg");
                if (BuildConfig.DEBUG) {
                    Log.d("ABC", String.format("response=%s(%s)", code, msg));
                }
                if (msg.equals("success")) {
                    HVCC2WDialogFragment.showConfirmAlert(getActivity(), getString(R.string.hw_name),
                            getString(R.string.c2w_setting_message_2_2), getString(R.string.button_gmail),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    Intent intent = new Intent(Intent.ACTION_MAIN);
                                    intent.setAction("android.intent.category.LAUNCHER");
                                    intent.setClassName("com.google.android.gm",
                                            "com.google.android.gm.ConversationListActivityGmail");
                                    intent.setFlags(0x10200000);
                                    startActivity(intent);

                                }
                            });
                } else {
                    HVCC2WDialogFragment.showAlert(getActivity(), getString(R.string.hw_name),
                            getString(R.string.c2w_setting_error_4), null);
                }
            } catch (JSONException e) {
                if (BuildConfig.DEBUG) {
                    e.printStackTrace();
                }
                HVCC2WDialogFragment.showAlert(getActivity(), getString(R.string.hw_name),
                        getString(R.string.c2w_setting_error_4), null);

            }
        }
    });
}

From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java

private List<String> getHomes() {
    List<String> names = new ArrayList<String>();
    try {/*from   w  ww. j  a v  a2 s  .  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:edu.mit.mobile.android.demomode.DemoMode.java

/**
 * Loads the list of installed applications in mApplications.
 *///from  ww  w .ja va  2  s. c o  m
private void loadApplications(boolean isLaunching) {
    if (isLaunching && mApplications != null) {
        return;
    }

    final PackageManager manager = getPackageManager();

    final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0);
    Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager));

    if (apps != null) {
        final int count = apps.size();

        if (mApplications == null) {
            mApplications = new ArrayList<ApplicationInfo>(count);
        }
        mApplications.clear();

        for (int i = 0; i < count; i++) {
            final ApplicationInfo application = new ApplicationInfo();
            final ResolveInfo info = apps.get(i);

            application.title = info.loadLabel(manager);
            application.setActivity(
                    new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name),
                    Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            application.icon = info.activityInfo.loadIcon(manager);

            mApplications.add(application);
        }
    }
}

From source file:com.filemanager.free.activities.Preferences.java

@Override
public void onBackPressed() {
    if (select == 1 && changed == 1)
        restartPC(this);
    else if (select == 1 || select == 2) {
        selectItem(0);//from   w w w  .j  a  v  a2s. com
    } else {
        Intent in = new Intent(Preferences.this, MainActivity.class);
        in.setAction(Intent.ACTION_MAIN);
        final int enter_anim = android.R.anim.fade_in;
        final int exit_anim = android.R.anim.fade_out;
        Activity activity = this;
        activity.overridePendingTransition(enter_anim, exit_anim);
        activity.finish();
        activity.overridePendingTransition(enter_anim, exit_anim);
        activity.startActivity(in);
    }
    MainActivity.showInterstitial();
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppReferenceObj.java

@Override
public void handleDirectMessage(Context context, Contact from, JSONObject obj) {
    String packageName = obj.optString(PACKAGE_NAME);
    String arg = obj.optString(ARG);
    Intent launch = new Intent();
    launch.setAction(Intent.ACTION_MAIN);
    launch.addCategory(Intent.CATEGORY_LAUNCHER);
    launch.putExtra(AppState.EXTRA_APPLICATION_ARGUMENT, arg);
    launch.putExtra("creator", false);
    launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    launch.setPackage(packageName);/*from  w w  w  .j av a2s. c om*/
    final PackageManager mgr = context.getPackageManager();
    List<ResolveInfo> resolved = mgr.queryIntentActivities(launch, 0);
    if (resolved == null || resolved.size() == 0) {
        Toast.makeText(context, "Could not find application to handle invite", Toast.LENGTH_SHORT).show();
        return;
    }
    ActivityInfo info = resolved.get(0).activityInfo;
    launch.setComponent(new ComponentName(info.packageName, info.name));
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch,
            PendingIntent.FLAG_CANCEL_CURRENT);

    (new PresenceAwareNotify(context)).notify("New Invitation", "Invitation received from " + from.name,
            "Click to launch application.", contentIntent);
}

From source file:org.tlhInganHol.android.klingonassistant.FloatingWindow.java

@Override
public List<DropDownListItem> getDropDownItems(int id) {
    List<DropDownListItem> items = new ArrayList<DropDownListItem>();
    items.add(new DropDownListItem(0, "Restore", new Runnable() {

        @Override//from  ww w  .j a va2 s  .c  o m
        public void run() {
            String query = mEditText.getText().toString();
            Intent intent = new Intent(FloatingWindow.this, KlingonAssistant.class);
            // This needs to be set since this is called outside of an activity.
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            // Starting as a main intent is needed to force the menudrawer to load.
            intent.setAction(Intent.ACTION_MAIN);
            startActivity(intent);
            if (!query.equals("")) {
                intent.setAction(Intent.ACTION_SEARCH);
                intent.putExtra(SearchManager.QUERY, query);
                startActivity(intent);
            }
        }
    }));
    return items;
}

From source file:com.chale22.ico01.fragments.FragmentTheme.java

private void applyAdwTheme() {
    try {/*from   w ww.j  a va  2s.  c  o  m*/
        Intent adwlauncherIntent = new Intent(Intent.ACTION_MAIN);
        adwlauncherIntent.setComponent(new ComponentName("org.adw.launcher", "org.adw.launcher.Launcher"));
        startActivity(adwlauncherIntent);
        makeToast("Apply with \"ADW Settings\" in Menu");
    } catch (ActivityNotFoundException e4) {
        e4.printStackTrace();
        makeToast("ADW Launcher is not installed!");
    }

}