I want to download a file from the Internet using the service. I found the source code and the code worked well. But I have a problem, when I return from the application, when the download stops or when I clear the RAM, it also stops. So I want to find a downloadable code, such as Google Play, that never stops when you clear RAM or application history. This is my source code:
public class Temp extends IntentService { public static final int UPDATE_PROGRESS = 8344; private int lastupdate=0; private NotificationManager nm; private Builder mBuilder; public Temp() { super("Temp"); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d("SERVICE-ONCOMMAND", "onStartCommand"); return START_STICKY; } @Override protected void onHandleIntent(Intent intent) { Log.e("ok","ok"); nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(this); mBuilder.setContentTitle( "Picture Download dnsadg sadgasjdgashgd asgd asjdg asjgd sajgd s") .setContentText("Download in progress") .setSmallIcon(R.drawable.icon_app).setContentInfo("0%"); mBuilder.setOngoing(true); File root = new File(Environment.getExternalStorageDirectory() + "/aaaa"); String urlToDownload = "http://dl2.mid.az/endir.php?file=uploads/Exclusive/miri_yusif_-_yoxam_men_mp3.mid.az.mp3";
Qafqaz
source share