当前位置: 首页 > 知识库问答 >
问题:

IntentService突然停止

申高峯
2023-03-14

我有一个稍微令人困惑的问题,我认为由于一个愚蠢的疏忽,这将是一个容易解决的问题。

我的主要任务是上传图像和录音文件到我的服务器上的一个位置。我通过FTP这样做。

  1. 活动通过startService(intentName)调用服务
  2. onHandleIntent()创建一个新线程
  3. 在新线程中,需要上传的文件被放入一个列表数组
  4. 在列表数组中循环。在这个循环中,将文件名传递给FTP服务器。如果添加成功,我会将此文件名添加到另一个包含已确认名称文件的ListArray中
  5. 循环完成后,我通过调用stopSelf()停止服务。
  6. 我创建一个通知,通知用户服务已完成

我对第4步有问题。循环只上载我的两个文件,然后突然停止。上传第二个文件时,手机会进入睡眠模式。没有通知。

我试过以下方法

  • 我最初使用AsyncWork,但这从来没有设法一次上传所有列出的文件。
  • 使用StrictMode.
  • 创建了第二个类,它是服务而不是IntentService。
  • 尝试start Foreground()-然而,这不是一个选项,因为这将杀死我的用户界面,我得到的应用程序不响应弹出窗口。

有人能提出一个前进的方向吗?这是我的密码

这是Main Activity.class中的代码

    Intent service = new Intent(getApplicationContext(), UploadMedia.class);
    service.putExtra("imageFileName", "/Folder/uploadtheseimagefiles.txt");
    service.putExtra("audioFileName", "/Folder/uploadtheseaudiofiles.txt");
    startService(service);

这是我的IntentService代码

protected void onHandleIntent(Intent intent) {
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    final String imageFileName = intent.getStringExtra("imageFileName");
    final String audioFileName = intent.getStringExtra("audioFileName");

    new Thread(new Runnable() {
        @Override
        public void run() {
            String serverAddress = "server address here";
            String userID = "user name here";
            String password = "password here";
            ArrayList<String> confirmed = new ArrayList<String>();

            //1. Upload the image files
            if (imageFileName.length() != 0) {
                File uploadContents = new File(imageFileName);
                if (uploadContents.exists()) {
                    try {
                        //Read the entries to be uploaded
                        InputStream ststr = new FileInputStream(uploadContents);
                        BufferedReader stbr = new BufferedReader(new InputStreamReader(ststr));
                        String line = "";
                        upData.clear();
                        while ((line  = stbr.readLine ()) != null) {
                            upData.add(line.trim());
                        }
                        stbr.close();
                        ststr.close();

                        //Upload the entries
                        confirmed.clear();
                        for(int i = 0; i < upData.size(); i++) {
                            if (new UploadViaFTP().ftpUpload(upData.get(i).toString(), serverAddress, userID, password)) {
                                confirmed.add(upData.get(i).toString());
                            }
                        }

                        //Check the uploaded filenames against the ones that were to be uploaded.
                        ArrayList<String> remaining = new ArrayList<String>();
                        for (int i = 0; i < upData.size(); i++) {
                            if (!confirmed.contains(upData.get(i)))
                                remaining.add(upData.get(i));
                        }

                        //If there are any remaining, write them back into the file.
                        if (remaining.size() != 0) {
                            try {
                                FileWriter fw = new FileWriter(imageFileName);
                                for (int i = 0; i < remaining.size(); i++) {
                                    fw.write(remaining.get(i));
                                    fw.append("\n");
                                }
                                fw.close();
                            } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }

                        } else { //All files have been uploaded
                            File delFile = new File(imageFileName);
                            if (delFile.exists())
                                delFile.delete();
                        }   
                    } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }

            //2. Upload the audio files
            if (audioFileName.length() != 0) {
                File uploadContents = new File(audioFileName);
                if (uploadContents.exists()) {
                    try {
                        //Read the entries to be uploaded
                        InputStream ststr = new FileInputStream(uploadContents);
                        BufferedReader stbr = new BufferedReader(new InputStreamReader(ststr));
                        String line = "";
                        upData.clear();
                        while ((line  = stbr.readLine ()) != null) {
                            upData.add(line.trim());
                        }
                        stbr.close();
                        ststr.close();

                        //Upload the entries
                        confirmed.clear();
                        for(int i = 0; i < upData.size(); i++) {
                            if (new UploadViaFTP().ftpUpload(upData.get(i).toString(), serverAddress, userID, password)) {
                                confirmed.add(upData.get(i).toString());
                            }
                        }

                        //Check the uploaded filenames against the ones that were to be uploaded.
                        ArrayList<String> remaining = new ArrayList<String>();
                        for (int i = 0; i < upData.size(); i++) {
                            if (!confirmed.contains(upData.get(i)))
                                remaining.add(upData.get(i));
                        }

                        //If there are any remaining, write them back into the file.
                        if (remaining.size() != 0) {
                            try {
                                FileWriter fw = new FileWriter(audioFileName);
                                for (int i = 0; i < remaining.size(); i++) {
                                    fw.write(remaining.get(i));
                                    fw.append("\n");
                                }
                                fw.close();
                            } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }

                        } else { //All files have been uploaded
                            File delFile = new File(audioFileName);
                            if (delFile.exists())
                                delFile.delete();
                        }   
                    } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }

            stopSelf();

            //Final check before notification. 
            File checkFile = new File("/Folder/uploadtheseimagefiles.txt");
            if (!checkFile.exists()) {
                checkFile = new File("/Folder/uploadtheseaudiofiles.txt");
                if (!checkFile.exists()) {
                    NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext())
                         .setSmallIcon(R.drawable.ic_launcher)
                         .setContentTitle("Something")
                         .setContentText("Uploading of media complete.");
                    Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
                   PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
                   builder.setContentIntent(contentIntent);

                   // Add as notification
                   NotificationManager manager = (NotificationManager) getSystemService(getApplication().NOTIFICATION_SERVICE);
                   manager.notify(0, builder.build());
                }
            }               
        }
    }).start();
}

Manifest.xml文件

    <service
        android:name=".UploadMedia"
        android:exported="true"
        android:enabled="true"/>

新信息:根据我的测试用例,失败总是发生在第二个文件上。第一个图像大小约为900KB,第二个图像大小约为2MB。在调试中,我无法获得第二个文件的FTPUpload状态。但是调试器停止了第一个文件,我可以继续。

新信息:第2部分:可能相关。我正在使用asynctask将一些数据更新到服务器上的数据库中。一旦成功返回,它会整理所有需要上传的文件名。这些经过整理的数据就是我将意图传递给服务的内容。

也是另一个忏悔。我有这个确切的过程运行和工作在我的另一个应用程序。在后执行方法上,它调用服务将数据上传到FTP服务器。我比较了清单文件、服务和对服务的调用,一切似乎都是一样的。

新信息:第3部分:日志文件

02-12 10:03:40.521: I/PERSONAL(14962): Calling the service
02-12 10:03:40.525: W/Binder_1(791): type=1400 audit(0.0:20440): avc: denied { ioctl } for path="socket:[743779]" dev="sockfs" ino=743779 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:03:40.525: W/Binder_1(791): type=1400 audit(0.0:20441): avc: denied { ioctl } for path="socket:[743779]" dev="sockfs" ino=743779 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:03:40.534: I/PERSONAL(14962): Uploading audio file 0
02-12 10:03:40.585: V/RenderScript(14962): 0xb397e000 Launching thread(s), CPUs 4
02-12 10:03:42.278: I/Finsky(14117): [3310] com.google.android.finsky.d.e.run(1151): Replicating app states via AMAS.
02-12 10:03:42.398: I/Finsky(14117): [3310] com.google.android.finsky.d.c.a(313): Completed 0 account content syncs with 0 successful.
02-12 10:03:42.400: I/Finsky(14117): [1] com.google.android.finsky.services.j.a(148): Installation state replication succeeded.
02-12 10:03:42.434: I/PERSONAL(14962): Uploading audio file 1
02-12 10:03:42.515: W/Binder_F(1876): type=1400 audit(0.0:20442): avc: denied { ioctl } for path="socket:[743796]" dev="sockfs" ino=743796 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:03:42.515: W/Binder_F(1876): type=1400 audit(0.0:20443): avc: denied { ioctl } for path="socket:[743796]" dev="sockfs" ino=743796 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:03:43.400: D/audio_hw_primary(201): disable_audio_route: reset and update mixer path: low-latency-playback
02-12 10:03:43.400: D/audio_hw_primary(201): disable_snd_device: snd_device(2: speaker)
02-12 10:03:44.222: I/PERSONAL(14962): Uploading image file 0
02-12 10:03:44.565: W/Binder_5(1372): type=1400 audit(0.0:20444): avc: denied { ioctl } for path="socket:[745643]" dev="sockfs" ino=745643 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:03:44.565: W/Binder_5(1372): type=1400 audit(0.0:20445): avc: denied { ioctl } for path="socket:[745643]" dev="sockfs" ino=745643 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:03:46.535: W/Binder_4(1220): type=1400 audit(0.0:20446): avc: denied { ioctl } for path="socket:[745654]" dev="sockfs" ino=745654 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:03:46.535: W/Binder_4(1220): type=1400 audit(0.0:20447): avc: denied { ioctl } for path="socket:[745654]" dev="sockfs" ino=745654 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:03:59.995: W/Binder_6(1388): type=1400 audit(0.0:20448): avc: denied { ioctl } for path="socket:[743809]" dev="sockfs" ino=743809 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:03:59.995: W/Binder_6(1388): type=1400 audit(0.0:20449): avc: denied { ioctl } for path="socket:[743809]" dev="sockfs" ino=743809 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:04:04.787: I/DeviceStateChecker(1718): screenOn: true, isCharging: true
02-12 10:04:29.560: D/NetlinkSocketObserver(781): NeighborEvent{elapsedMs=152656259, fe80::86c9:b2ff:fe6c:5ce9, [84C9B26C5CE9], RTM_NEWNEIGH, NUD_PROBE}
02-12 10:04:29.705: I/PlayCommon(14117): [3292] com.google.android.play.a.g.e(909): Preparing logs for uploading
02-12 10:04:29.733: I/PlayCommon(14117): [3292] com.google.android.play.a.g.a(1049): Connecting to server: https://play.googleapis.com/play/log?format=raw&proto_v2=true
02-12 10:04:29.901: I/PERSONAL(14962): Uploading image file 1
02-12 10:04:29.971: I/PlayCommon(14117): [3315] com.google.android.play.a.g.e(909): Preparing logs for uploading
02-12 10:04:29.972: I/PlayCommon(14117): [3315] com.google.android.play.a.g.e(911): No file ready to send
02-12 10:04:31.635: I/PlayCommon(14117): [3292] com.google.android.play.a.g.a(1127): Successfully uploaded logs.
02-12 10:04:46.450: D/NetlinkSocketObserver(781): NeighborEvent{elapsedMs=152673149, fe80::86c9:b2ff:fe6c:5ce9, [84C9B26C5CE9], RTM_NEWNEIGH, NUD_STALE}
02-12 10:04:58.348: V/GsmInboundSmsHandler(1549): Unable to find carrier package: [], nor systemPackages: []
02-12 10:04:58.363: D/MmsService(1549): getAutoPersisting
02-12 10:04:58.377: I/ActivityManager(781): Start proc 15147:com.google.android.talk/u0a27 for broadcast com.google.android.talk/com.google.android.apps.hangouts.sms.SmsDeliverReceiver
02-12 10:04:59.064: D/BabelGcmRegistration(15147): GcmRegistration: Checking GCM registration
02-12 10:04:59.079: I/Babel_telephony(15147): TeleModule.onApplicationCreate
02-12 10:04:59.089: I/Babel_SMS(15147): MmsConfig: mnc/mcc: 404/86
02-12 10:04:59.090: I/Babel_SMS(15147): MmsConfig.loadMmsSettings
02-12 10:04:59.091: I/Babel_SMS(15147): MmsConfig.loadDeviceMmsSettings from API: userAgent=Nexus5, uaProfUrl=http://gsm.lge.com/html/gsm/Nexus5-M3.xml
02-12 10:04:59.091: I/Babel_SMS(15147): MmsConfig.loadFromDatabase
02-12 10:04:59.105: E/SQLiteLog(15147): (1) no such table: mmsconfig
02-12 10:04:59.107: I/Babel_SMS(15147): MmsConfig: no mmsconfig table android.database.sqlite.SQLiteException: no such table: mmsconfig (code 1): , while compiling: SELECT key, value, type FROM mmsconfig WHERE numeric=?
02-12 10:04:59.107: I/Babel_SMS(15147): MmsConfig.loadFromResources
02-12 10:04:59.118: I/Babel_Prime(15147): wrapCrashReportingIntoUncaughtExceptionHandler
02-12 10:04:59.119: E/Babel_SMS(15147): canonicalizeMccMnc: invalid mccmnc nullnull
02-12 10:04:59.121: I/Babel_SMS(15147): MmsConfig.loadMmsSettings: userAgent=Nexus5, uaProfUrl=http://gsm.lge.com/html/gsm/Nexus5-M3.xml
02-12 10:04:59.126: I/Babel_App(15147): Startup - clean
02-12 10:04:59.128: I/Babel_SMS(15147): ApnsOta: OTA version -1
02-12 10:04:59.134: I/Babel(15147): Invalid account: 3 isEmptyName: true nameEqualsGaiaId: false
02-12 10:04:59.169: I/Babel_Prime(15147): isMemoryEnabled=false
02-12 10:04:59.169: I/Babel_Prime(15147): isTimerEnabled=false
02-12 10:04:59.169: I/Babel_Prime(15147): isCrashCounterEnabled=true
02-12 10:04:59.170: I/Babel_Prime(15147): primesPackageConfigurationsProvider=false
02-12 10:04:59.172: I/Babel(15147): Deleting: false for 3
02-12 10:04:59.174: I/Babel_Prime(15147): startMemoryMonitor
02-12 10:04:59.233: D/Babel(15147): created account premthomas@gmail.com => Redacted-20-chars
02-12 10:04:59.263: W/FortumoInApp(5700): Broadcast is disabled, there is no sense, to countinue.
02-12 10:04:59.274: I/Babel_ConcService(15147): Binding ConcurrentService
02-12 10:04:59.280: I/ActivityManager(781): Killing 13354:com.android.settings/1000 (adj 15): empty #17
02-12 10:04:59.341: D/ActivityManager(781): cleanUpApplicationRecord -- 13354
02-12 10:04:59.367: I/Babel_ConcService(15147): Acquired partial wake lock to keep ConcurrentService alive
02-12 10:04:59.514: W/IcingInternalCorpora(1644): getNumBytesRead when not calculated.
02-12 10:04:59.518: I/Icing(1644): Usage reports 0 indexed 0 rejected 0 imm upload false
02-12 10:04:59.672: W/linker(15147): /data/app/com.google.android.gms-2/lib/arm/libgmscore.so: unused DT entry: type 0x7ffffffd arg 0x795
02-12 10:04:59.689: W/linker(15147): /data/app/com.google.android.gms-2/lib/arm/libconscrypt_gmscore_jni.so: unused DT entry: type 0x1d arg 0xe0
02-12 10:04:59.689: W/linker(15147): /data/app/com.google.android.gms-2/lib/arm/libconscrypt_gmscore_jni.so: unused DT entry: type 0x7ffffffd arg 0x1cb
02-12 10:04:59.697: V/JNIHelp(15147): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 242 native methods...
02-12 10:04:59.712: I/art(15147): Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.OpenSSLExtendedSessionImpl>
02-12 10:04:59.713: I/art(15147): Rejecting re-init on previously-failed class java.lang.Class<com.google.android.gms.org.conscrypt.OpenSSLExtendedSessionImpl>
02-12 10:04:59.768: I/ProviderInstaller(15147): Installed default security provider GmsCore_OpenSSL
02-12 10:04:59.823: W/VideoCapabilities(15147): Unrecognized profile 2130706433 for video/avc
02-12 10:04:59.848: I/VideoCapabilities(15147): Unsupported profile 4 for video/mp4v-es
02-12 10:04:59.858: W/VideoCapabilities(15147): Unrecognized profile 2130706433 for video/avc
02-12 10:04:59.859: W/VideoCapabilities(15147): Unrecognized profile 2130706433 for video/avc
02-12 10:04:59.862: W/VideoCapabilities(15147): Unrecognized profile 2130706433 for video/avc
02-12 10:04:59.927: D/NuPlayerDriver(201): reset(0xb3876600)
02-12 10:04:59.927: D/NuPlayerDriver(201): notifyListener_l(0xb3876600), (8, 0, 0)
02-12 10:04:59.927: D/NuPlayerDriver(201): notifyResetComplete(0xb3876600)
02-12 10:04:59.942: I/Babel_ConcService(15147): Released partial wake lock as ConcurrentService became idle
02-12 10:05:00.041: D/NuPlayerDriver(201): notifyListener_l(0xb34b8720), (1, 0, 0)
02-12 10:05:00.041: D/MediaPlayer(921): setSubtitleAnchor in MediaPlayer
02-12 10:05:00.044: I/MediaFocusControl(781):  AudioFocus  requestAudioFocus() from android.media.AudioManager@dd2779c req=3flags=0x0
02-12 10:05:00.045: D/NuPlayerDriver(201): start(0xb34b8720), state is 4, eos is 0
02-12 10:05:00.045: I/GenericSource(201): start
02-12 10:05:00.053: E/OMXNodeInstance(201): setConfig(103:google.vorbis.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-12 10:05:00.053: I/ACodec(201): codec does not support config priority (err -2147483648)
02-12 10:05:00.054: I/MediaCodec(201): MediaCodec will operate in async mode
02-12 10:05:00.060: D/Babel_RtcImpressions(15147): Type: 1926
02-12 10:05:00.072: D/PhoneStatusBar(921): disable: < expand ICONS* alerts SYSTEM_INFO* back home recent clock search quick_settings >
02-12 10:05:00.075: D/audio_hw_primary(201): out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
02-12 10:05:00.087: D/NuPlayerDriver(201): notifyListener_l(0xb34b8720), (6, 0, 0)
02-12 10:05:00.096: D/audio_hw_primary(201): select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
02-12 10:05:00.096: D/msm8974_platform(201): platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
02-12 10:05:00.096: D/audio_hw_primary(201): enable_snd_device: snd_device(2: speaker)
02-12 10:05:00.099: D/audio_hw_primary(201): enable_audio_route: apply and update mixer path: low-latency-playback
02-12 10:05:00.122: D/CountryDetector(781): The first listener is added
02-12 10:05:00.639: I/Babel(15147): connection state changed from UNKNOWN to CONNECTED
02-12 10:05:00.869: I/NuPlayerDecoder(201): [audio] saw output EOS
02-12 10:05:01.271: D/NuPlayerDriver(201): notifyListener_l(0xb34b8720), (2, 0, 0)
02-12 10:05:01.271: I/MediaFocusControl(781):  AudioFocus  abandonAudioFocus() from android.media.AudioManager@dd2779c
02-12 10:05:04.252: D/audio_hw_primary(201): disable_audio_route: reset and update mixer path: low-latency-playback
02-12 10:05:04.253: D/audio_hw_primary(201): disable_snd_device: snd_device(2: speaker)
02-12 10:05:04.883: W/IcingInternalCorpora(1644): getNumBytesRead when not calculated.
02-12 10:05:04.915: I/Icing(1644): Usage reports 0 indexed 0 rejected 0 imm upload false
02-12 10:05:05.932: I/Icing(1644): Indexing D2350FC178F0C3C6D9357237E165CCBC64772E44 from com.google.android.gms
02-12 10:05:06.040: I/Icing(1644): Indexing done D2350FC178F0C3C6D9357237E165CCBC64772E44
02-12 10:05:06.057: D/PhoneStatusBar(921): disable: < expand icons* alerts system_info* back home recent clock search quick_settings >
02-12 10:05:14.171: I/Babel_ConcService(15147): Acquired partial wake lock to keep ConcurrentService alive
02-12 10:05:14.182: I/Babel_ConcService(15147): Released partial wake lock as ConcurrentService became idle
02-12 10:05:18.751: I/ProcessStatsService(781): Prepared write state in 3ms
02-12 10:05:18.753: I/ProcessStatsService(781): Prepared write state in 2ms
02-12 10:05:29.137: I/Telecom(781): PhoneAccountRegistrar: SimCallManager queried, returning: null
02-12 10:05:29.143: I/Babel_telephony(15147): TeleModule.updateConnectionManagerRegistration, registration preference changed from false to false
02-12 10:05:29.143: W/Babel(15147): BAM#gBA: invalid account id: -1
02-12 10:05:29.144: W/Babel(15147): BAM#gBA: invalid account id: -1
02-12 10:05:29.144: I/Babel_telephony(15147): TeleModule.updateIncomingCallRegistration, preferred account for incoming calls changed from: null to null
02-12 10:05:29.151: I/Telecom(781): PhoneAccountRegistrar: SimCallManager queried, returning: null
02-12 10:05:49.090: I/PowerManagerService(781): Going to sleep due to screen timeout (uid 1000)...
02-12 10:05:49.175: W/Binder_3(958): type=1400 audit(0.0:20450): avc: denied { ioctl } for path="socket:[743742]" dev="sockfs" ino=743742 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:05:49.175: W/Binder_3(958): type=1400 audit(0.0:20451): avc: denied { ioctl } for path="socket:[743742]" dev="sockfs" ino=743742 ioctlcmd=7704 scontext=u:r:system_server:s0 tcontext=u:r:system_server:s0 tclass=unix_stream_socket permissive=0
02-12 10:05:49.091: I/PowerManagerService(781): Sleeping (uid 1000)...
02-12 10:05:49.665: V/KeyguardServiceDelegate(781): onScreenTurnedOff()

我会接受任何建议/问题。

共有2个答案

潘坚白
2023-03-14

您不需要调用stopSelf(),因为当队列中没有要服务的请求时,IntentService会自动停止。

添加更多的日志语句,以找出为什么它要在上传所有文件之前停止Self。

席兴朝
2023-03-14

为什么要在onHandleIndent中创建新线程?这个方法已经从后台线程调用了,因此它不会妨碍你的UI呈现或其他什么。只需在onHandleIntent方法中直接运行逻辑即可。试试看

 类似资料:
  • 问题内容: 我使用JavaFX NumberBindings来计算某些值。最初,一切正常。但是,经过相当短的时间后,绑定将停止工作。我也没有收到例外。 我已经尝试了几种绑定以及高级和低级方法。即使计算本身(被覆盖时)也只是停止并且不再被调用。我还更新到了最新的JDK(1.8.0_05),并重新构建/重新启动了所有内容。 以下最小工作示例说明了该问题。它应该将System.out.println主窗

  • 问题内容: 我们的Jenkins构建开始在一夜之间因错误而失败: Jenkins服务器仍在运行Java 6,但我们没有做任何更改。 发生了什么,我们如何解决? 问题答案: 该詹金斯-声纳插件使用声纳Maven的插件来运行声纳分析。 Sonar-maven-plugin已于2015-10-19更新至2.7,新版本与Java 6不兼容。 Jenkins-sonar-plugin默认使用最新版本的son

  • 我们的Jenkins构建在一夜之间开始失败,错误如下: Jenkins服务器仍然运行Java6,但我们没有改变任何东西。 发生了什么,我们如何解决?

  • 我的应用程序中正在运行IntentService。当用户按下“取消”按钮时,我想停止,但onHandleIntent会继续运行,即使在调用onDestroy(IntentService)时也是如此。 在执行过程中,我尝试了StSelfFe(),StutoIn(int)和StestService(意图),但不起作用。 我试图从碎片中停下来 提前感谢

  • 我正在使用IntentService将图像上传到服务器。我的问题是我不知道如何/何时停止服务。当我在onHandleIntent(意图..)中调用stopself()时将删除在IntentService队列中等待的所有意图。但我不想停止活动中的服务,因为我想完成上传过程,即使我的应用程序没有运行。

  • 我的Visual Studio Code有问题。昨天我在打开VS Code的情况下关闭了我的电脑,当我再次打开电脑时,所有VS Code扩展都停止了工作。我在项目中使用React和Types cript,我真的需要这些扩展。我的eslint和漂亮的配置也停止了工作。如果有人有同样的问题,请回答。