English 中文(简体)
ent底栖物种如何相配?
原标题:How are Intent-Categories matched?
  • 时间:2010-09-01 23:39:32
  •  标签:
  • android

我拿不上“仁爱的配对”概念! 我必须找不到一些东西,但我读读并重新读一下,没有。 难道有某种灵魂能够让人们看到这一点吗?

如果我具体说明“过滤器编码”类别,那么我就能够开始活动。

    ...
    <activity 
        android:name="mmmo.android.test.ItemDetails"
        <intent-filter>
            <action android:name="android.intent.action.INSERT" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    ...

并且如果我没有加入任何类别的反对:

        ...
        Intent intent = new Intent(Intent.ACTION_INSERT);
        startActivity(intent);
        ...

这一工作。 然而,一旦我界定了除<代码>android.intent. 类别以外的任何其他类别。 我只读到<条码>活性编号<>。 例如,如果我具体说明:

    ...
    <activity 
        android:name="mmmo.android.test.ItemDetails"
        <intent-filter>
            <action android:name="android.intent.action.INSERT" />
                    <category android:name="foo.bar" />
        </intent-filter>
    </activity>
    ...

接着利用:

        ...
        Intent intent = new Intent(Intent.ACTION_INSERT);
        intent.addCategory("foo.bar"); 
        startActivity(intent);
        ...

这并不可行。 斜体为:“...... object物体中的每一类都必须与过滤器中的一类相匹配。 ...... 添加“第一类”与“过滤器”中具体规定的第一类相匹配。 因此,这为什么不相称,而只是放弃一个例外?

Michael M.

最佳回答

你们也必须补充。

 <category android:name="android.intent.category.DEFAULT"></category>

目的是要解决。

活动往往需要支持《禁止酷刑和其他残忍、不人道或有辱人格的待遇或处罚公约》。

问题回答

http://developer.android.com/guide/topics/intents/intents-filters.html

In principle, therefore, an Intent object with no categories should always pass this test, regardless of what s in the filter. That s mostly true. However, with one exception, Android treats all implicit intents passed to startActivity() as if they contained at least one category: "android.intent.category.DEFAULT" (the CATEGORY_DEFAULT constant). Therefore, activities that are willing to receive implicit intents must include "android.intent.category.DEFAULT" in their intent filters

如果可观察到的行为与其所记录的行为不相称,就会出现“丑闻”。 这不是 make。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签