Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 记事本问题:getIntent()和set数据(通过引用?)_Android_Android Intent - Fatal编程技术网

Android 记事本问题:getIntent()和set数据(通过引用?)

Android 记事本问题:getIntent()和set数据(通过引用?),android,android-intent,Android,Android Intent,因此,我试图理解记事本示例中的所有代码,但我遇到了一些困难: 首先,如何判断我们的项目是从“X”文件开始的?像“索引”文件 (我猜它是从NoteList页面开始的)在这个NoteList页面中,我们使用getIntent()获取当前意图,然后从中获取数据:但是: 哪个活动启动了注释列表?(我认为没有,而且这个项目中的所有活动都有这个getIntent()方法,所以当项目启动时是否有一个intent自动“发送”过来?) 我们将数据设置为新的intent变量,但随后我们将数据按如下方式拉入光标:g

因此,我试图理解记事本示例中的所有代码,但我遇到了一些困难:

首先,如何判断我们的项目是从“X”文件开始的?像“索引”文件

(我猜它是从NoteList页面开始的)在这个NoteList页面中,我们使用getIntent()获取当前意图,然后从中获取数据:但是:

  • 哪个活动启动了注释列表?(我认为没有,而且这个项目中的所有活动都有这个getIntent()方法,所以当项目启动时是否有一个intent自动“发送”过来?)
  • 我们将数据设置为新的intent变量,但随后我们将数据按如下方式拉入光标:
    getIntent().getData()
    :它是通过“引用”还是类似的方式传递的?所以使用新的intent变量或getIntent()是一样的
谢谢你的帮助;-)

>


NoteList是应用程序的主要入口点。请参阅AndroidManifest.xml以查看启动器和主意图过滤器

 <activity android:name="NotesList" android:label="@string/title_notes_list">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <action android:name="android.intent.action.PICK" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.GET_CONTENT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
        </intent-filter>
    </activity>


每个活动都是由一个意图开始的。在活动中调用getIntent()。此调用返回启动它的意图对象。在记事本中,NoteID-(是一个URI)作为Intent对象中的一个参数从一个活动传递到。

谢谢Rajdeep Dua,所以当启动
NoteList
时(当我们启动应用程序时),没有任何活动启动它,那么这个“getIntent()”包含什么?嗨,Rajdeep,不知道我的问题吗?
 <activity android:name="NotesList" android:label="@string/title_notes_list">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <action android:name="android.intent.action.PICK" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.GET_CONTENT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
        </intent-filter>
    </activity>