Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doWork() doesn't make what I want #84

Open
milenacarolinelt opened this issue Aug 18, 2017 · 5 comments
Open

doWork() doesn't make what I want #84

milenacarolinelt opened this issue Aug 18, 2017 · 5 comments

Comments

@milenacarolinelt
Copy link

I'm trying to make a background notification service, but anything I do on doWork doesn't work. I don't know that I do, I just put some logs for testing, but doesn't work too.
I edit the MyService.java whitout IDE or whatever, could be that?

package com.red_folder.phonegap.plugin.backgroundservice.sample;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import com.red_folder.phonegap.plugin.backgroundservice.BackgroundService;

public class MyService extends BackgroundService {
	
	private final static String TAG = "MILENA SERVICE";
	
	private String mHelloTo = "Merda!!";

	@Override
	protected JSONObject doWork() {
		JSONObject result = new JSONObject();
		
		try {
            SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
            String now = df.format(new Date(System.currentTimeMillis()));
            String msg = "QQQQQQQQQ - " + now;
            result.put("Message", msg);
            result.put("HUEHUE", msg);
            Log.e("MilenaService", "QQQQQQQQQ - " + now);
            Log.e("MilenaService", "NAO VAI ESSA MERDA DE APP");
            Log.e("MilenaService", "Service");
            Log.e("MilenaService", msg);
        } catch (JSONException e) {
            Log.e("MilenaService", e.getMessage());
        }
		
		return result;	
	}

	@Override
	protected JSONObject getConfig() {
		JSONObject result = new JSONObject();
		
		try {
			result.put("HelloTo", this.mHelloTo);
			result.put("HUEHUE", "QQQQQQQQQ -");
		} catch (JSONException e) {
		}
		
		return result;
	}

	@Override
	protected void setConfig(JSONObject config) {
		try {
			if (config.has("HelloTo"))
				this.mHelloTo = config.getString("HelloTo");
		} catch (JSONException e) {
		}
		
	}     

	@Override
	protected JSONObject initialiseLatestResult() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void onTimerEnabled() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void onTimerDisabled() {
		// TODO Auto-generated method stub
		
	}


}
@milenacarolinelt milenacarolinelt changed the title doWork() don't make what I want doWork() doesn't make what I want Aug 18, 2017
@Red-Folder
Copy link
Owner

I assume you have built this out from bgp-sample? Was it working before you changed it?

It will be very difficult to provide any advice without an actual problem.

@milenacarolinelt
Copy link
Author

milenacarolinelt commented Aug 18, 2017

Yes, I used bgp-sample. Still working, but on the console it shows what you had in the bg-simple example instead of what I did

08-18 12:18:54.415 17240-17303/com.phonegap.helloworld D/MyService: Hello World - its currently 18/08/2017 12:18:54
08-18 12:19:54.415 17240-17303/com.phonegap.helloworld D/MyService: Hello World - its currently 18/08/2017 12:19:54
08-18 12:20:54.415 17240-17303/com.phonegap.helloworld D/MyService: Hello World - its currently 18/08/2017 12:20:54
08-18 12:21:54.415 17240-17303/com.phonegap.helloworld D/MyService: Hello World - its currently 18/08/2017 12:21:54
08-18 12:22:54.415 17240-17303/com.phonegap.helloworld D/MyService: Hello World - its currently 18/08/2017 12:22:54
08-18 12:23:54.415 17240-17303/com.phonegap.helloworld D/MyService: Hello World - its currently 18/08/2017 12:23:54

@Red-Folder
Copy link
Owner

I'm sorry I don't understand

What is the question?

@milenacarolinelt
Copy link
Author

I changed doWork e execute apk on celphone, but it's still work like original bg-simple. I need to compile or something else for it execute the new doWork? Sorry, my english it's not very good.

@Red-Folder
Copy link
Owner

Yes you will need to recompile to get any changes into your apk. You will also need to install that new apk to your cellphone to see the change there.

I suggest spending some time understanding the Android development process - otherwise you are likely to struggle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants