Home>

I linked the two apps, and when I pressed the button, I moved the app with Intent, but sometimes I didn't know when to skip the Intent.

External App Launch Intent Issue Summary I implemented it, but I don't understand the setAction part.
I understand that it is only necessary to put the package name and activity name of the transition destination in the setClassName part, but

android.intent.category.LAUNCHER"

I didn't know what this string was doing. What is this string specified for setAction, or is it a fixed value every time you pass Intent?

  • Answer # 1

    There is something wrong with the page.

    setAction specifies an action, and if you specify a place that has already been specified in the constructor argument, you will overwrite it. If executed with the code according to the page, the log output will be

    I/ActivityManager (757): START u0 {act = android.intent.category.LAUNCHER flg = 0x10200000 cmp = com.google.android.apps.plus/.phone.HomeActivity} from pid 20121


    Like, act should become android.intent.category.LAUNCHER. If you want to reproduce the log output as in the previous section, the category is

    intent.addCategory ("android.intent.category.LAUNCHER");// cat
    Or
    intent.addCategory (Intent.CATEGORY_LAUNCHER);// cat


    (Intent.CATEGORY_LAUNCHER's entity is".android.intent.category.LAUNCHER" ;, so it doesn't matter which one you specify.) Well, leave that.

    For the question subject, this is a feature called implicit intent. If you set with a method such as setAction (same as the argument to the constructor) or addCategory and skip the intent, the activity that matches the condition will open. If there are multiple matches, you will be asked which one to open. If you select an image file in the file manager in normal terminal operation, you may have seen a display asking which viewer you want to open, but it feels like that.

    For example,

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


    If you just run it, all the top activities of the apps registered in the launcher will be targeted, so an inquiry that includes all of them will come out.

    If you specify another application you created by package name as long as you specify it with setClassName, there should be no duplicates only with this condition, so this should only open the target activity (if it does not exist) It falls)