JobScheduler在几分钟后停止工作 - cn1

时间:2017-11-02 08:59:41

标签: codenameone

我希望每隔几分钟就能获得一次GPS定位。我已经使用jobScheduler使用本机界面在后台运行它,它可以工作几分钟。只要它给getGoogleAppId失败并显示状态:10错误,该应用就会停止工作。之后它没有在调试中给出任何消息。 Plz看看下面的错误日志。三江源

主要形式:

public void start() {
    if(current != null){
        current.show();
        return;
    }
    na = (Native) NativeLookup.create(Native.class);
    if (na != null && na.isSupported()) {
        Log.p("native interface");
        na.getFusedLocationPermission();
        na.jobSchedulerMethod();
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    hi.add(new Label("Hi World"));
    hi.show();
}   

Native.java

public interface Native extends NativeInterface{
    public void getFusedLocationPermission();
    public void jobSchedulerMethod();
}

NativeImpl.class

public class NativeImpl {

    JobScheduler jobScheduler;
    private static final int MYJOBID = 1;

    public boolean isSupported() {
        return true;
    }

    public void getFusedLocationPermission() {
        if (!com.codename1.impl.android.AndroidNativeUtil.checkForPermission(android.Manifest.permission.ACCESS_FINE_LOCATION, "Please allow location permission")) {
            // you didn't get the permission, you might want to return here
//            ActivityCompat.requestPermissions((android.app.Activity) MyApplication.getContext(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
//            Log.e("permission", "you didn't get the permission, you might want to return here");
        }
    }

    public void jobSchedulerMethod() {
        Context context = AndroidNativeUtil.getContext();
        Activity activity = AndroidNativeUtil.getActivity();
        jobScheduler = (JobScheduler) activity.getSystemService("jobscheduler");

        ComponentName jobService
                = new ComponentName(context.getPackageName(), MyJobService.class.getName());
        JobInfo jobInfo
                = new JobInfo.Builder(MYJOBID, jobService).setPeriodic(120000).build();

        int jobId = jobScheduler.schedule(jobInfo);
        if (jobScheduler.schedule(jobInfo) > 0) {
            Log.e("job", "Successfully scheduled job: ");
        } else {
            Log.e("job", "RESULT_FAILURE: ");
        }

    }

}

错误日志1:" getGoogleAppId失败,状态为:10",此行后该应用停止运行。

11-02 11:52:20.931 1824-1853/com.capitaleyenepal.nokia E/job: Successfully scheduled job: 
11-02 11:52:20.941 1824-1853/com.capitaleyenepal.nokia I/System.out: showKeyboard false
11-02 11:52:20.961 1824-1853/com.capitaleyenepal.nokia D/Codename One: sizechanged: 1080 1848 com.codename1.impl.android.CodenameOneView@cc84777
11-02 11:52:20.971 1824-1854/com.capitaleyenepal.nokia D/libGLESv1: STS_GLApi : DTS is not allowed for Package : com.capitaleyenepal.nokia
11-02 11:54:21.081 1824-1824/com.capitaleyenepal.nokia V/ActivityThread: updateVisibility : ActivityRecord{416dfe4 token=android.os.BinderProxy@18f4fee {com.capitaleyenepal.nokia/com.capitaleyenepal.nokia.nokiaStub}} show : true
11-02 11:55:30.501 1824-1824/com.capitaleyenepal.nokia D/NokiaApp: [main] 0:3:9,600 - gps
11-02 11:55:30.511 1824-1824/com.capitaleyenepal.nokia I/System.out: gps checkGPS running
11-02 11:55:31.681 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734582
11-02 11:55:36.681 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734578
11-02 11:55:46.741 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734585
11-02 11:55:51.761 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734582
11-02 11:56:01.781 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734595
11-02 11:56:06.781 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734543
11-02 11:56:11.791 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734539
11-02 11:56:16.811 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734587
11-02 11:56:26.811 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734592
11-02 11:56:31.861 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734566
11-02 11:56:36.811 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734566
11-02 11:56:41.851 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734582
11-02 11:56:46.891 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734544
11-02 11:56:51.871 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734552
11-02 11:56:56.871 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734583
11-02 11:57:01.881 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734574
11-02 11:57:06.921 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734572
11-02 11:57:11.921 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734582
11-02 11:57:16.931 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734562
11-02 11:57:21.941 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734558
11-02 11:57:26.911 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734578
11-02 11:57:31.061 1824-1824/com.capitaleyenepal.nokia D/NokiaApp: [main] 0:5:10,153 - gps
11-02 11:57:31.061 1824-1824/com.capitaleyenepal.nokia I/System.out: gps checkGPS running
11-02 11:57:31.951 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734585
11-02 11:57:37.251 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734579
11-02 11:57:42.281 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734587
11-02 11:57:47.281 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734587
11-02 11:57:52.281 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6734594
11-02 11:57:57.331 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6740921
11-02 11:57:58.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6741087
11-02 11:57:59.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6740856
11-02 11:58:00.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6740856
11-02 11:58:08.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6739376
11-02 11:58:09.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6739368
11-02 11:58:10.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6739125
11-02 11:58:11.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6738705
11-02 11:58:12.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6738842
11-02 11:58:13.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6738967
11-02 11:58:14.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6738931
11-02 11:58:15.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6738768
11-02 11:58:16.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6738634
11-02 11:58:17.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6738513
11-02 11:58:18.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6738286
11-02 11:58:19.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737996
11-02 11:58:20.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737891
11-02 11:58:21.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737915
11-02 11:58:22.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.67378
11-02 11:58:23.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737786
11-02 11:58:25.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.673768
11-02 11:58:26.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737631
11-02 11:58:27.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737799
11-02 11:58:28.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.673775
11-02 11:58:29.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737811
11-02 11:58:30.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737817
11-02 11:58:32.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737301
11-02 11:58:33.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737309
11-02 11:58:34.611 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737088
11-02 11:58:35.601 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737008
11-02 11:58:36.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6736802
11-02 11:58:37.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6736677
11-02 11:58:38.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6736791
11-02 11:58:39.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6736922
11-02 11:58:40.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.673699
11-02 11:58:41.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737056
11-02 11:58:42.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737083
11-02 11:58:43.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737064
11-02 11:58:44.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737282
11-02 11:58:45.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737348
11-02 11:58:46.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737396
11-02 11:58:47.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737422
11-02 11:58:48.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737375
11-02 11:58:49.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737326
11-02 11:58:50.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737596
11-02 11:58:51.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737669
11-02 11:58:52.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.673765
11-02 11:58:53.581 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737602
11-02 11:58:54.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.673767
11-02 11:58:55.541 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.673767
11-02 11:58:56.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737592
11-02 11:58:57.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737599
11-02 11:58:58.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.673758
11-02 11:58:59.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737605
11-02 11:59:00.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737605
11-02 11:59:01.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737685
11-02 11:59:02.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737885
11-02 11:59:03.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737965
11-02 11:59:04.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6737916
11-02 11:59:06.581 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6738007
11-02 11:59:10.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.673696
11-02 11:59:11.591 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6736834
11-02 11:59:14.581 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6736759
11-02 11:59:17.581 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6736457
11-02 11:59:19.581 1824-1853/com.capitaleyenepal.nokia I/System.out: locationUpdated longitudeeee 27.6736243
11-02 11:59:22.011 2044-2044/com.capitaleyenepal.nokia W/ResourcesManager: Resource getTopLevelResources for package com.capitaleyenepal.nokiaoverlayDirs =Null
11-02 11:59:22.021 2044-2044/com.capitaleyenepal.nokia W/System: ClassLoader referenced unknown path: /data/app/com.capitaleyenepal.nokia-1/lib/arm
11-02 11:59:22.021 2044-2044/com.capitaleyenepal.nokia D/ContextRelationManager: ContextRelationManager() : FEATURE_ENABLED=true
11-02 11:59:22.071 2044-2060/com.capitaleyenepal.nokia I/GMPM: App measurement is starting up
11-02 11:59:22.081 2044-2060/com.capitaleyenepal.nokia E/GMPM: getGoogleAppId failed with status: 10
11-02 11:59:22.081 2044-2060/com.capitaleyenepal.nokia E/GMPM: Uploading is not possible. App measurement disabled

enter image description here

构建提示:

android.xpermissions - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

0 个答案:

没有答案