本文介绍了muzei - 致命异常:IntentService [TaskQueueService]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创造muzei艺术源(插件)。

I'm trying to create an art source ( plugin ) for muzei.

该应用程序应该提供一种新的艺术来源,在我的情况是我的应用程序,私人空间的文件夹。

The app is supposed to provide a new art source which in my case is a folder of my app-private space.

随着从muzei API的,它提供这里我创建了一个FileProvider我的应用程序。

Following the example from the muzei api here and the details it provides here I created a FileProvider for my app.

我加入这个code到我的清单:

I have added this code to my manifest :

           <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="com.foo.bar.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/muzei_wallpapers" />
          </provider>

我创建的XML文件 muzei_wallpapers 在我的RES / XML文件夹:

I created the xml file muzei_wallpapers in my res/xml folder :

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path name="my_images" path="files/"  />
</paths>

和,你可以看到它指向我的文件/ 文件夹中。

and as you can see it points to my files/ folder.

和最后一个是我的课扩展 MuzeiArtSource

And last is my class that extends MuzeiArtSource :

public class MuzeiService extends MuzeiArtSource {

Uri imgUri;


public MuzeiService() {
    super(MuzeiService.class.getName());
}


@Override
public void onCreate() {
    super.onCreate();
   // setUserCommands(BUILTIN_COMMAND_ID_NEXT_ARTWORK); // manual switch image         
}

@Override
protected void onUpdate(int arg0) {

       imgUri = muzeiContentUri();  

    publishArtwork(new Artwork.Builder()
           .imageUri( Uri.parse("imgUri") )
           .title("Example image")
           .byline("Unknown person, c. 1980")
           .build());       
}



public Uri muzeiContentUri()    {
    File imagePath = new File(getFilesDir(), "files");
    File newFile = new File(imagePath, "wallpaper0.png");
    Uri contentUri = FileProvider.getUriForFile(getApplicationContext(), "com.foo.bar.fileprovider", newFile);

    return contentUri;
}



}

这似乎给我,我可以返回URI为一个简单的文件最简单的例子

(名为wallpapaper0)

Which seems to me the simplest example I can have returning the uri for a simple file ( named wallpapaper0 )

当我选择以资源为muzei我的应用程序我得到一个不幸的是muzei已停止和logcat的是:

When I select as resource for muzei my app I get an "unfortunately muzei has stopped" and the logcat is :

      05-28 04:29:40.350: E/AndroidRuntime(3670): FATAL EXCEPTION:      IntentService[TaskQueueService]
05-28 04:29:40.350: E/AndroidRuntime(3670): java.lang.NullPointerException
05-28 04:29:40.350: E/AndroidRuntime(3670):     at      com.google.android.apps.muzei.util.IOUtil.readFullyWriteToOutputStream(IOUtil.java:210)
 05-28 04:29:40.350: E/AndroidRuntime(3670):    at      com.google.android.apps.muzei.util.IOUtil.readFullyWriteToFile(IOUtil.java:202)
05-28 04:29:40.350: E/AndroidRuntime(3670):     at      com.google.android.apps.muzei.ArtworkCache.maybeDownloadCurrentArtworkSync(ArtworkCache.java:122)
05-28 04:29:40.350: E/AndroidRuntime(3670):     at      com.google.android.apps.muzei.TaskQueueService.onHandleIntent(TaskQueueService.java:56)
05-28 04:29:40.350: E/AndroidRuntime(3670):     at     android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
05-28 04:29:40.350: E/AndroidRuntime(3670):     at     android.os.Handler.dispatchMessage(Handler.java:99)
05-28 04:29:40.350: E/AndroidRuntime(3670):     at android.os.Looper.loop(Looper.java:137)
05-28 04:29:40.350: E/AndroidRuntime(3670):     at android.os.HandlerThread.run(HandlerThread.java:61)

我真的AP preciate任何帮助,因为我坚持了下来最后的日子里,我觉得我在这里失踪简单的东西...

I would really appreciate any help cause I'm stuck with it the last days and I feel like I'm missing something simple here...

推荐答案

正在传递 Uri.parse(imgUri) - 你应该只传递 imgUri

You are passing in Uri.parse("imgUri") - you should just be passing in imgUri:

imgUri = muzeiContentUri();  

publishArtwork(new Artwork.Builder()
       .imageUri(imgUri)
       .title("Example image")
       .byline("Unknown person, c. 1980")
       .build());

这篇关于muzei - 致命异常:IntentService [TaskQueueService]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 23:34