Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.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 如何将意向从我的一个应用发送到我的另一个应用?_Android_Android Intent_Android Service - Fatal编程技术网

Android 如何将意向从我的一个应用发送到我的另一个应用?

Android 如何将意向从我的一个应用发送到我的另一个应用?,android,android-intent,android-service,Android,Android Intent,Android Service,我有一个类IntentService,它位于com.mypackage.app1.receiver(第一个应用程序): 我在舱单中登记: <service android:name=".IntentService" > <intent-filter> <action android:name="com.mypackage.START_INTENT"/> <category android:name="com.myp

我有一个类
IntentService
,它位于
com.mypackage.app1.receiver
(第一个应用程序):

我在舱单中登记:

<service android:name=".IntentService" >
    <intent-filter>
        <action android:name="com.mypackage.START_INTENT"/>
        <category android:name="com.mypackage.category.DEFAULT"/>
        <data android:mimeType="text/plain"/>
    </intent-filter>
</service>
不幸的是,
IntentService
目前没有收到
SenderActivity
发送的意图。我必须做什么才能收到它?

更换:

<service android:name=".IntentService" >
    <intent-filter>
        <action android:name="com.mypackage.START_INTENT"/>
        <category android:name="com.mypackage.category.DEFAULT"/>
        <data android:mimeType="text/plain"/>
    </intent-filter>
</service>

与:


以匹配您与
startService()
一起使用的
意图

此外,由于有一个名为IntentService的Android SDK类,我建议您将服务的名称更改为其他名称。

替换:

<service android:name=".IntentService" >
    <intent-filter>
        <action android:name="com.mypackage.START_INTENT"/>
        <category android:name="com.mypackage.category.DEFAULT"/>
        <data android:mimeType="text/plain"/>
    </intent-filter>
</service>

与:


以匹配您与
startService()
一起使用的
意图

另外,由于有一个名为
IntentService
的Android SDK类,我建议您将服务的名称更改为其他名称

<service android:name=".IntentService" >
    <intent-filter>
        <action android:name="com.mypackage.START_INTENT"/>
        <category android:name="com.mypackage.category.DEFAULT"/>
        <data android:mimeType="text/plain"/>
    </intent-filter>
</service>
<service android:name=".IntentService" >
    <intent-filter>
        <action android:name="com.learningleaflets.START_INTENT"/>
    </intent-filter>
</service>