Unable to start service Intent U=0: not found

记录平常遇见的问题

Unable to start service Intent { act=com.py.wifidirect.SEND_FILE 
cmp=com.py.wifidirect/.FileTransferService (has extras) } U=0: not found

启动Service的代码如下:

Intent serviceIntent = new Intent(getActivity(), FileTransferService.class);
serviceIntent.setAction("com.py.wifidirect.SEND_FILE");
getActivity().startService(serviceIntent);

后来发现AndroidManifest.xml中未注册service,需要添加注册信息。

<service android:enabled="true"
    android:name=".FileTransferService" >
    <intent-filter>
        <action android:name="com.py.wifidirect.SEND_FILE" />
    intent-filter>
service>

你可能感兴趣的:(Android,遇见的问题)