Android 서비스에 문제가 있습니다. 서비스에서 사용자 정의 클래스를 작성했습니다. 스레드에서 사용자 정의 클래스를 작성했습니다.앱을 종료 한 후 맞춤 서비스에서 맞춤 스레드를 실행하십시오.
내 서비스가 알림을 보내기 위해 프로그램을 파괴 한 후에 작동하도록하고 싶지만 모든 것이 정상이지만 사용자 정의 클래스는 삭제 후 작동하지 않지만 중지 또는 일시 중지 앱에서는 서비스가 올바르게 작동합니다.
이 문제를 해결할 수 있도록 도와주세요.
ServiceNotification.class
import Threadcustom;
public class ServiceNotification extends Service {
@Override
public void onCreate() {
super.onCreate();
}
@Override
public int onStartCommand(final Intent intent, int flags, int startId) {
GlobalController.timerTaskService = new TimerTask() {
@Override
public void run() {
Threadcustom threadc = new Threadcustom();
threadc.setDetail("1");
threadc.start();
Threadcustom threadc1 = new Threadcustom();
threadc1.setDetail("2");
threadc1.start();
if (threadc.newMessage == 1) {
CustomNotification customNotification = new CustomNotification();
customNotification.notifiaction("my message");
}
}
};
GlobalController.timerService.schedule(GlobalController.timerTaskService, 0, 5000);
return Service.START_STICKY;
}
public void onTaskRemoved(Intent rootIntent) {
Intent restartService = new Intent(getApplicationContext(),
this.getClass());
restartService.setPackage(getPackageName());
PendingIntent restartServicePI = PendingIntent.getService(
getApplicationContext(), 1, restartService,
PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 5000, restartServicePI);
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public void onRebind(Intent intent) {
super.onRebind(intent);
}
}
manifest.xml
<receiver
android:name=".services.ServiceBootCompleteReciver"
android:enabled="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
<service
android:name=".services.ServiceNotification"
android:enabled="true"
android:exported="false"
/>
Threadcustom.class
public class ThreadSms extends Thread {
@Override
public void run() {
super.run();
define my url
define http url connection get data from url then insert data to sqlite database in my application.
}
내 스레드 작업 스레드 내 서비스 작업을 수정 및 알림을 보내지 만 후에 파괴 응용 프로그램 알림 작업을하지만 내 사용자 정의 스레드는 호출하지 않으며, 어떤 프로그램도 충돌하지 않습니다. 당신이 또한 당신이 당신의 서비스가 실행되지 않았거나 확인/실행하는 타이머를 사용할 수있는 OS
에 의해 살해되는 것을 원하지 않는 경우
ClassLoader referenced unknown path: /data/app/app.myapp/lib/arm
ClassLoader referenced unknown path: /system/framework/tcmclient.jar
tnanks man, 제 문제는 해결되었습니다. – user3750973
@ user3750973 환영 친구 –
화면 잠김 또는 잠자기가 작동하면 어떻게됩니까? 화면 잠금 또는 수면 전화기에서 작업 할 수 있습니까 ????? – user3750973