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.dmcc.chatlibrary.ui.EaseBaseActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    //http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/
    //?launcher activity,?app???
    if (!isTaskRoot()) {
        Intent intent = getIntent();//ww  w  .ja va 2  s.c om
        String action = intent.getAction();
        if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)) {
            finish();
            return;
        }
    }
}

From source file:com.sentaroh.android.SMBSync.NotificationUtil.java

@SuppressWarnings("deprecation")
static final public void initNotification(GlobalParameters gwa) {
    gwa.notificationManager = (NotificationManager) gwa.svcContext
            .getSystemService(Context.NOTIFICATION_SERVICE);
    gwa.notification = new Notification(R.drawable.ic_32_smbsync, gwa.svcContext.getString(R.string.app_name),
            0);/*from   ww w.  j a  v a2s .c om*/

    gwa.notificationAppName = gwa.svcContext.getString(R.string.app_name);

    gwa.notificationIntent = new Intent(gwa.svcContext, SMBSyncMain.class);
    gwa.notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    gwa.notificationIntent.setAction(Intent.ACTION_MAIN);
    gwa.notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    gwa.notificationPendingIntent = PendingIntent.getActivity(gwa.svcContext, 0, gwa.notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    gwa.notificationBuilder = new NotificationCompat.Builder(gwa.svcContext);
    gwa.notificationBuilder.setContentIntent(gwa.notificationPendingIntent)
            //            .setTicker(gwa.notificationAppName)
            .setOngoing(true).setAutoCancel(false).setSmallIcon(gwa.notificationIcon)//smbsync_animation)
            .setContentTitle(gwa.notificationAppName).setContentText("")
            //          .setSubText("subtext")
            //          .setLargeIcon(largeIcon)
            .setWhen(0)
    //         .addAction(action_icon, action_title, action_pi)
    ;
    gwa.notification = gwa.notificationBuilder.build();
    if (Build.VERSION.SDK_INT >= 16) {//JB(4.1
        gwa.notificationBigTextStyle = new NotificationCompat.BigTextStyle(gwa.notificationBuilder);
        gwa.notificationBigTextStyle.setBigContentTitle(gwa.notificationLastShowedTitle)
                .bigText(gwa.notificationLastShowedMessage);
    }

}

From source file:com.sentaroh.android.TextFileBrowser.NotificationUtil.java

@SuppressWarnings("deprecation")
static final public void initNotification(Context c, NotificationCommonParms gwa) {
    gwa.notificationManager = (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE);
    gwa.notification = new Notification(R.drawable.ic_32_browse_text, c.getString(R.string.app_name), 0);

    gwa.notificationAppName = c.getString(R.string.app_name);

    gwa.notificationIntent = new Intent(c, MainActivity.class);
    gwa.notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    gwa.notificationIntent.setAction(Intent.ACTION_MAIN);
    gwa.notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    gwa.notificationPendingIntent = PendingIntent.getActivity(c, 0, gwa.notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    buildNotification(c, gwa);/*www . j  a v a  2  s  . c  o m*/
}

From source file:com.sentaroh.android.SMBSync2.NotificationUtil.java

@SuppressWarnings("deprecation")
static final public void initNotification(GlobalParameters gwa) {
    gwa.notificationManager = (NotificationManager) gwa.appContext
            .getSystemService(Context.NOTIFICATION_SERVICE);
    gwa.notification = new Notification(R.drawable.ic_48_smbsync_wait,
            gwa.appContext.getString(R.string.app_name), 0);

    gwa.notificationAppName = gwa.appContext.getString(R.string.app_name);

    gwa.notificationIntent = new Intent(gwa.appContext, ActivityMain.class);
    gwa.notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    gwa.notificationIntent.setAction(Intent.ACTION_MAIN);
    gwa.notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    gwa.notificationPendingIntent = PendingIntent.getActivity(gwa.appContext, 0, gwa.notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    gwa.notificationLargeIcon = BitmapFactory.decodeResource(gwa.appContext.getResources(),
            gwa.notificationSmallIcon);//from  www . ja v a  2  s .com
    gwa.notificationBuilder = new NotificationCompat.Builder(gwa.appContext);
    gwa.notificationBuilder.setContentIntent(gwa.notificationPendingIntent)
            //            .setTicker(gwa.notificationAppName)
            .setOngoing(true).setAutoCancel(false).setSmallIcon(R.drawable.ic_48_smbsync_wait)//smbsync_animation)
            .setLargeIcon(gwa.notificationLargeIcon).setContentTitle(gwa.notificationAppName).setContentText("")
            //          .setSubText("subtext")
            //          .setLargeIcon(largeIcon)
            .setWhen(0)
    //         .addAction(action_icon, action_title, action_pi)
    ;
    gwa.notification = gwa.notificationBuilder.build();
    gwa.notificationBigTextStyle = new NotificationCompat.BigTextStyle(gwa.notificationBuilder);
    gwa.notificationBigTextStyle.setBigContentTitle(gwa.notificationLastShowedTitle)
            .bigText(gwa.notificationLastShowedMessage);

}

From source file:org.duckdns.raven.ttscallresponder.ui.notification.CallReceiverNotificationFactory.java

public Notification buildCallReceiverNotification(boolean enabled) {
    String newText = null;/*from  w  ww  . j  av a2 s .  c  o m*/

    // Create Text
    newText = "AutoResponder ";
    if (enabled) {
        newText += "enabled";
    } else {
        newText += "disabled";
    }

    // Create Notification
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this.context)
            .setContentTitle(this.context.getResources().getString(R.string.app_name)).setContentText(newText)
            .setSmallIcon(R.drawable.ic_launcher).setOngoing(true);

    // Create Intent
    Intent bringMainToFront = new Intent(this.context, MainActivity.class);
    bringMainToFront.setAction(Intent.ACTION_MAIN);
    bringMainToFront.addCategory(Intent.CATEGORY_LAUNCHER);
    PendingIntent resultPendingIntent = PendingIntent.getActivity(this.context, 0, bringMainToFront, 0);
    mBuilder.setContentIntent(resultPendingIntent);

    return mBuilder.build();
}

From source file:love.juhe.androidmonkey.MonkeyActivityEvent.java

/**
 * @return Intent for the new activity/*  ww  w . j  a v a  2s .c om*/
 */
private Intent getEvent() {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(mApp);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}

From source file:com.callba.phone.ui.ease.EaseBaseActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    //http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/
    //?launcher activity,?app???
    if (!isTaskRoot()) {
        Intent intent = getIntent();/*from www  .  ja  v  a2s .  c  om*/
        String action = intent.getAction();
        if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)) {
            finish();
            return;
        }
    }

    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
}

From source file:cn.xcom.helper.chat.easeui.ui.EaseBaseActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    //http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/
    // should be in launcher activity, but all app use this can avoid the problem
    if (!isTaskRoot()) {
        Intent intent = getIntent();// w ww.  j av a2 s.  c  o  m
        String action = intent.getAction();
        if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)) {
            finish();
            return;
        }
    }

    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
}

From source file:com.lchtime.safetyexpress.ui.chat.hx.activity.EaseBaseActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    //http://stackoverflow.com/questions/4341600/how-to-prevent-multiple-instances-of-an-activity-when-it-is-launched-with-differ/
    // should be in launcher activity, but all app use this can avoid the problem
    if (!isTaskRoot()) {
        Intent intent = getIntent();//ww w .  j  a v a2  s  .co m
        String action = intent.getAction();
        if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action.equals(Intent.ACTION_MAIN)) {
            finish();
            return;
        }
    }
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
}

From source file:mobisocial.socialkit.musubi.Musubi.java

public static boolean isMusubiInstalled(Context context) {
    try {//from   w w  w  . j  a  va  2  s. c  o  m
        final Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setPackage(SUPER_APP_ID);
        return context.getPackageManager().queryIntentActivities(intent, 0).size() > 0;
    } catch (Throwable t) {
        return false;
    }
}