Skip to content

invalid service notification error while uploading image #85

Closed
@vipul1905

Description

@vipul1905

I am trying to single image. But I get the following error

An uncaught Exception occurred on "main" thread.
android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid service notification: Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x42 color=0x00000000 groupKey=net.gotev vis=PRIVATE)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1768)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6494)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

This is the upload function:

 displayImage(){
        var documents = fs.knownFolders.temp();

        documents.getEntities()
        .then((entities)=>{
            // entities is array with the document's files and folders.
            entities.forEach((entity)=>{
                console.log(entity);
                console.log(entity.path);
                
                let token = appSettings.getString("token");
                console.log(token);
                if (token != ''){

                    var request = {
                        url:  url
                        method: "POST",
                        headers: {
                            "Content-Type": "application/octet-stream",
                            "File-Name": entity.path,
                            "Authorization": "Bearer " + token  
                        },
                        description: "{ 'uploading': 'bigpig.jpg' }"
                    };
                    
                    var task = session.uploadFile(entity.path, request);
                    
                    task.on("progress", this.logEvent);
                    task.on("error", this.logEvent);
                    task.on("complete", this.logEvent);
                    
                   
              }
            });
        }, function (error) {
            // Failed to obtain folder's contents.
            // globalConsole.error(error.message);
        });

the entity path is " /data/user/0/org.testApp.testApp/cache/savedImage1510757546373.jpg". I tried to save the image to the temp folder of the emulator and find the file and upload to the server.

Could anyone tell me what is missing? and what this error means? Any help would be much appreciated. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions