I'm a few days, the problem with Android service. I wrote custom Class from service I wrote custom class from thread.
I want my service to work after destroy program for send notification, everything is OK but custom class not working after destroy but in stop or pause app, my service work correct.
Please help me fix this problem.
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.
}
my thread work correct my service work with thread and send notification,but after destroy app notification work but my custom thread not call, any program not crash only said warning
ClassLoader referenced unknown path: /data/app/app.myapp/lib/arm
ClassLoader referenced unknown path: /system/framework/tcmclient.jar