문제

I have a service that supposed to upload photos in the background. But when I try to start it, it doesn't start. In the logcat I've noticed that I get a warning Implicit intents with startService are not safe : Intent { .....}. I've already tripled checked that the action string is the same in the manifest and what I'm starting with. My code :
manifest :

<service android:name=".photosupload.services.PhtosUploadService" 
  android:exported="false" android:process=":uploadPhotosServiceProcess">
  <intent-filter>
    <action android:name="com.yoovi.app.photosupload.services.action.START_UPLOAD" />
  </intent-filter>
</service>

starting service code :

  Intent i = new Intent(PhtosUploadService.ACTION_START_UPLOAD);
  i.putExtra(PhtosUploadService.ALBUM_ID, albumID);
  context.startService(i);
도움이 되었습니까?

해결책

You need to understand implicit and explicit intents.

Explicit intent means you need to specify the exact class from which the intent will be serviced.

Your code should be similar to

    Intent i = new Intent();  
i.setClass(this, photosupload.services.PhtosUploadService.class);

다른 팁

If you want to send implicit intent to a service - Please Change to android:exported="true" in manifest.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top