Android Open Source - android_Findex Index Service






From Project

Back to project page android_Findex.

License

The source code is released under:

Apache License

If you think the Android project android_Findex listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lithidsw.findex.service;
/*from  w  w  w  .  j  av  a2 s  .co m*/
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.IBinder;
import android.support.v4.app.NotificationCompat;

import com.lithidsw.findex.R;
import com.lithidsw.findex.MainActivity;
import com.lithidsw.findex.utils.C;
import com.lithidsw.findex.utils.FileWalker;
import com.lithidsw.findex.widget.WidgetUtils;

public class IndexService extends Service {

    Context context;

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        context = this;
        start();
        return (START_NOT_STICKY);
    }

    @Override
    public void onDestroy() {
        stopForeground(true);
    }

    private void start() {
        final Thread thread = new Thread() {
            @Override
            public void run() {
                new FileWalker(context).main();
                stopSelf();
                WidgetUtils.update(context);
                sendBroadcast(new Intent(C.ACTION_INDEX_COMPLETE));
            }
        };
        thread.start();
        fg(context.getResources().getString(R.string.index_running));
    }

    private void fg(String message) {
        Bitmap bit = BitmapFactory.decodeResource(getResources(),
                R.drawable.ic_launcher);
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                context)
                .setSmallIcon(R.drawable.ic_launcher)
                .setLargeIcon(bit)
                .setProgress(0, 0, true)
                .setContentTitle(context.getResources().getString(R.string.app_name))
                .setContentText(message);

        Intent intent = new Intent(context, MainActivity.class);
        intent.setAction(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);

        PendingIntent resultPendingIntent = PendingIntent.getActivity(context,
                0, intent, 0);
        mBuilder.setContentIntent(resultPendingIntent);
        startForeground(1, mBuilder.build());
    }
}




Java Source Code List

com.lithidsw.findex.AddTagActivity.java
com.lithidsw.findex.FileInfoActivity.java
com.lithidsw.findex.IntroActivity.java
com.lithidsw.findex.IntroFragment.java
com.lithidsw.findex.MainActivity.java
com.lithidsw.findex.MainFragment.java
com.lithidsw.findex.SettingsActivity.java
com.lithidsw.findex.adapter.DrawerListAdapter.java
com.lithidsw.findex.adapter.FilePageAdapter.java
com.lithidsw.findex.adapter.InfoTagListAdapter.java
com.lithidsw.findex.adapter.StorageListAdapter.java
com.lithidsw.findex.adapter.WidgetListAdapter.java
com.lithidsw.findex.db.DBHelper.java
com.lithidsw.findex.db.DBUtils.java
com.lithidsw.findex.ef.DirectoryAdapter.java
com.lithidsw.findex.ef.DirectoryListActivity.java
com.lithidsw.findex.ef.DirectoryManager.java
com.lithidsw.findex.info.DirPickerInfo.java
com.lithidsw.findex.info.FileInfo.java
com.lithidsw.findex.loader.ImageLoader.java
com.lithidsw.findex.loader.MemoryCache.java
com.lithidsw.findex.receiver.ActionReceiver.java
com.lithidsw.findex.service.IndexService.java
com.lithidsw.findex.utils.C.java
com.lithidsw.findex.utils.DateBuilder.java
com.lithidsw.findex.utils.FileStartActivity.java
com.lithidsw.findex.utils.FileUtils.java
com.lithidsw.findex.utils.FileWalker.java
com.lithidsw.findex.utils.ItemCountLoader.java
com.lithidsw.findex.utils.MrToast.java
com.lithidsw.findex.utils.StorageOptions.java
com.lithidsw.findex.widget.WidgetConfigActivity.java
com.lithidsw.findex.widget.WidgetInfo.java
com.lithidsw.findex.widget.WidgetLoadStub.java
com.lithidsw.findex.widget.WidgetProvider.java
com.lithidsw.findex.widget.WidgetService.java
com.lithidsw.findex.widget.WidgetUtils.java
com.lithidsw.findex.widget.WidgetViews.java