Example usage for android.content Intent CATEGORY_LAUNCHER

List of usage examples for android.content Intent CATEGORY_LAUNCHER

Introduction

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

Prototype

String CATEGORY_LAUNCHER

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

Click Source Link

Document

Should be displayed in the top-level launcher.

Usage

From source file:com.amaze.carbonfilemanager.activities.PreferencesActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // Navigate "up" the demo structure to the launchpad activity.
        if (selectedItem != START_PREFERENCE && changed)
            restartPC(this);
        else if (selectedItem != START_PREFERENCE) {
            selectItem(START_PREFERENCE);
        } else {/*w ww.j a  va  2  s .  c o m*/
            Intent in = new Intent(PreferencesActivity.this, MainActivity.class);
            in.setAction(Intent.ACTION_MAIN);
            in.setAction(Intent.CATEGORY_LAUNCHER);

            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);
        }
        return true;
    }
    return true;
}

From source file:com.redhorse.quickstart.AppConfig.java

private void loadApps() {
    Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    mAllApps = getPackageManager().queryIntentActivities(mainIntent, 0);
    mApps = new ArrayList<ResolveInfo>();
    mApps2 = new ArrayList<ResolveInfo>();
    Cursor c = dbStart.getAllItems();
    Iterator it1 = mAllApps.iterator();
    while (it1.hasNext()) {
        boolean found = false;
        ResolveInfo info = (ResolveInfo) it1.next();
        if (c.moveToFirst()) {
            do {/*from   w w  w  . j  a va2 s  . c  o  m*/
                int idColumn = c.getColumnIndex(dbStart.KEY_ROWID);
                int pkgnameColumn = c.getColumnIndex(dbStart.KEY_PKGNAME);
                int appnameColumn = c.getColumnIndex(dbStart.KEY_APPNAME);
                int contentColumn = c.getColumnIndex(dbStart.KEY_CONTENT);
                if (c.getString(pkgnameColumn).equals(info.activityInfo.packageName)
                        && c.getString(appnameColumn).equalsIgnoreCase(info.activityInfo.name)) {
                    found = true;
                    break;
                }
            } while (c.moveToNext());
        }
        if (!found)
            if (!info.activityInfo.packageName.equalsIgnoreCase("com.redhorse.quickstart"))
                mApps.add(info);
    }
    if (c.moveToFirst()) {
        do {
            int idColumn = c.getColumnIndex(dbStart.KEY_ROWID);
            int pkgnameColumn = c.getColumnIndex(dbStart.KEY_PKGNAME);
            int appnameColumn = c.getColumnIndex(dbStart.KEY_APPNAME);
            int contentColumn = c.getColumnIndex(dbStart.KEY_CONTENT);
            it1 = mAllApps.iterator();
            boolean found = false;
            ResolveInfo info = null;
            while (it1.hasNext()) {
                info = (ResolveInfo) it1.next();
                if (c.getString(pkgnameColumn).equals(info.activityInfo.packageName)
                        && c.getString(appnameColumn).equalsIgnoreCase(info.activityInfo.name)) {
                    found = true;
                    break;
                }
            }
            if (found)
                if (!info.activityInfo.packageName.equalsIgnoreCase("com.redhorse.quickstart"))
                    mApps2.add(info);
        } while (c.moveToNext());
    }
    c.close();
}

From source file:com.dm.material.dashboard.candybar.helpers.ReportBugsHelper.java

@Nullable
private static String buildActivityList(Context context, File folder) {
    try {//from  w w  w.  ja va  2s  .c o m
        File fileDir = new File(folder.toString() + "/" + "activity_list.xml");
        Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileDir), "UTF8"));

        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);

        List<ResolveInfo> appList = context.getPackageManager().queryIntentActivities(intent,
                PackageManager.GET_RESOLVED_FILTER);

        try {
            Collections.sort(appList, new ResolveInfo.DisplayNameComparator(context.getPackageManager()));
        } catch (Exception ignored) {
        }

        boolean first = true;
        for (ResolveInfo app : appList) {

            if (first) {
                first = false;
                out.append("<!-- ACTIVITY LIST -->");
                out.append("\n\n\n");
            }

            String name = app.activityInfo.loadLabel(context.getPackageManager()).toString();
            String activity = app.activityInfo.packageName + "/" + app.activityInfo.name;
            out.append("<!-- ").append(name).append(" -->");
            out.append("\n").append(activity);
            out.append("\n\n");
        }
        out.flush();
        out.close();

        return fileDir.toString();
    } catch (Exception | OutOfMemoryError e) {
        Log.d(Tag.LOG_TAG, Log.getStackTraceString(e));
    }
    return null;
}

From source file:com.google.android.apps.dashclock.gmail.GmailExtension.java

@Override
protected void onUpdateData(int reason) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    String labelCanonical = sp.getString(PREF_LABEL, "i");
    Set<String> selectedAccounts = getSelectedAccounts();

    if ("i".equals(labelCanonical)) {
        labelCanonical = GmailContract.Labels.LabelCanonicalNames.CANONICAL_NAME_INBOX;
    } else if ("p".equals(labelCanonical)) {
        labelCanonical = GmailContract.Labels.LabelCanonicalNames.CANONICAL_NAME_PRIORITY_INBOX;
    }/*from   w  w w  . j  ava2 s . com*/

    int unread = 0;
    List<Pair<String, Integer>> unreadPerAccount = new ArrayList<Pair<String, Integer>>();
    String lastUnreadLabelUri = null;

    for (String account : selectedAccounts) {
        Cursor cursor = tryOpenLabelsCursor(account);
        if (cursor == null || cursor.isAfterLast()) {
            LOGD(TAG, "No Gmail inbox information found for account.");
            if (cursor != null) {
                cursor.close();
            }
            continue;
        }

        int accountUnread = 0;

        while (cursor.moveToNext()) {
            int thisUnread = cursor.getInt(LabelsQuery.NUM_UNREAD_CONVERSATIONS);
            String thisCanonicalName = cursor.getString(LabelsQuery.CANONICAL_NAME);
            if (labelCanonical.equals(thisCanonicalName)) {
                accountUnread = thisUnread;
                if (thisUnread > 0) {
                    lastUnreadLabelUri = cursor.getString(LabelsQuery.URI);
                }
                break;
            } else if (!TextUtils.isEmpty(thisCanonicalName)
                    && thisCanonicalName.startsWith(SECTIONED_INBOX_CANONICAL_NAME_PREFIX)) {
                accountUnread += thisUnread;
                if (thisUnread > 0 && SECTIONED_INBOX_CANONICAL_NAME_PERSONAL.equals(thisCanonicalName)) {
                    lastUnreadLabelUri = cursor.getString(LabelsQuery.URI);
                }
            }
        }

        if (accountUnread > 0) {
            unreadPerAccount.add(new Pair<String, Integer>(account, accountUnread));
            unread += accountUnread;
        }

        cursor.close();
    }

    StringBuilder body = new StringBuilder();
    for (Pair<String, Integer> pair : unreadPerAccount) {
        if (pair.second == 0) {
            continue;
        }

        if (body.length() > 0) {
            body.append("\n");
        }
        body.append(pair.first).append(" (").append(pair.second).append(")");
    }

    Intent clickIntent = null;
    if (lastUnreadLabelUri != null) {
        try {
            clickIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(lastUnreadLabelUri));
            if (getPackageManager().resolveActivity(clickIntent, 0) == null) {
                throw new IllegalStateException("Gmail can't open this label directly.");
            }
        } catch (Exception e) {
            LOGW(TAG, "Can't open Gmail label directly.", e);
            clickIntent = null;
        }
    }

    if (clickIntent == null) {
        clickIntent = new Intent(Intent.ACTION_MAIN).setPackage("com.google.android.gm")
                .addCategory(Intent.CATEGORY_LAUNCHER);
    }

    publishUpdate(new ExtensionData().visible(unread > 0).status(Integer.toString(unread))
            .expandedTitle(getResources().getQuantityString(R.plurals.gmail_title_template, unread, unread))
            .icon(R.drawable.ic_extension_gmail).expandedBody(body.toString()).clickIntent(clickIntent));
}

From source file:com.google.android.testing.nativedriver.server.AndroidNativeDriver.java

/** Start a new activity either in a new task or the current task. */
public void startActivity(Class<?> activityClass) {
    Intent intent = new Intent(context.getInstrumentation().getContext(), activityClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    context.getInstrumentation().startActivitySync(intent);
}

From source file:org.spinsuite.bchat.util.BCNotificationHandle.java

/**
 * Instance Notification Manager/*from w  ww.j  a v  a2s  .c om*/
 * @author Yamel Senih, ysenih@erpcya.com, ERPCyA http://www.erpcya.com
 * @return void
 */
private void instanceNM(String p_SPS_BC_Request_UUID) {
    if (m_NotificationManager == null) {
        m_NotificationManager = (NotificationManager) m_Ctx.getSystemService(Context.NOTIFICATION_SERVICE);
    }
    //   
    m_Builder = new NotificationCompat.Builder(m_Ctx);
    Intent intent = new Intent(m_Ctx, V_BChat.class);
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    //   Add Parameter Request
    intent.putExtra("SPS_BC_Request_UUID", p_SPS_BC_Request_UUID);
    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    //   Set Main Activity
    PendingIntent m_PendingIntent = PendingIntent.getActivity(m_Ctx, 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    m_Builder.setContentIntent(m_PendingIntent);
    m_Builder.setAutoCancel(true);
    //   Set Vibration
    m_Builder.setVibrate(new long[] { 1000, 500, 1000, 500, 1000 });
    //   Set Light
    m_Builder.setLights(Color.GREEN, 3000, 3000);
    //   Set Sound
    Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    m_Builder.setSound(alarmSound);
}

From source file:com.emotiona.study.listviewpage.SwipeMenuListViewFragment.java

private void open(ApplicationInfo item) {
    // open app//from ww  w  .  j a v a  2  s .  c  o m
    Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
    resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    resolveIntent.setPackage(item.packageName);
    List<ResolveInfo> resolveInfoList = getActivity().getPackageManager().queryIntentActivities(resolveIntent,
            0);
    if (resolveInfoList != null && resolveInfoList.size() > 0) {
        ResolveInfo resolveInfo = resolveInfoList.get(0);
        String activityPackageName = resolveInfo.activityInfo.packageName;
        String className = resolveInfo.activityInfo.name;

        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        ComponentName componentName = new ComponentName(activityPackageName, className);

        intent.setComponent(componentName);
        startActivity(intent);
    }
}

From source file:com.hmsoft.weargoproremote.services.WearMessageHandlerService.java

void updateNotification(String contentText) {
    if (mNotificationBuilder == null) {
        Context context = getApplicationContext();
        Intent activityIntent = new Intent(context, MobileMainActivity.class);
        activityIntent.setAction(Intent.ACTION_MAIN);
        activityIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        activityIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NEW_TASK);

        Intent stopIntent = new Intent(context, WearMessageHandlerService.class);
        stopIntent.setAction(ACTION_STOP);

        mNotificationBuilder = (new Builder(this)).setSmallIcon(R.drawable.icon_notification)
                .setContentTitle(getString(R.string.notification_tittle))
                .setContentIntent(PendingIntent.getActivity(context, 0, activityIntent, 0)).setLocalOnly(true)
                .addAction(R.drawable.icon_power, getString(R.string.action_stop),
                        PendingIntent.getService(context, 0, stopIntent, 0));
    }// w  ww . j  a v a  2s.c o m

    mNotificationBuilder.setContentText(contentText);
    startForeground(1, mNotificationBuilder.build());
}

From source file:jahirfiquitiva.iconshowcase.tasks.LoadAppsToRequest.java

private Intent getAllActivitiesIntent() {
    Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    return mainIntent;
}