Search in sources :

Example 1 with Preferences

use of com.spazedog.mounts2sd.tools.Preferences in project mounts2sd by SpazeDog.

the class ReceiverBoot method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
        new Thread() {

            private Context mContext;

            public Thread putContext(Context context) {
                mContext = context;
                return this;
            }

            @Override
            public void run() {
                String message = null;
                RootFW root = Root.initiate();
                if (root.isConnected()) {
                    Preferences preferences = Preferences.getInstance(mContext);
                    if (!preferences.deviceSetup.load(true) || !preferences.deviceConfig.load(true) || !preferences.deviceProperties.load(true)) {
                        message = mContext.getResources().getString(R.string.notify_no_config);
                    } else if (preferences.deviceSetup.log_level() > 1) {
                        message = mContext.getResources().getString(R.string.notify_log_details);
                    }
                } else {
                    message = mContext.getResources().getString(R.string.notify_no_config);
                }
                if (message != null) {
                    NotificationManager manager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
                    NotificationCompat.Builder notification = new NotificationCompat.Builder(mContext).setContentIntent(PendingIntent.getActivity(mContext, 0, new Intent(mContext, ActivityTabController.class), 0)).setSmallIcon(R.drawable.ic_launcher).setWhen(System.currentTimeMillis()).setAutoCancel(true).setContentTitle(mContext.getApplicationInfo().name).setContentText(message);
                    manager.notify(1, notification.build());
                }
                Root.release();
            }
        }.putContext(context.getApplicationContext()).start();
    }
}
Also used : Context(android.content.Context) NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Preferences(com.spazedog.mounts2sd.tools.Preferences) RootFW(com.spazedog.lib.rootfw3.RootFW)

Aggregations

NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 Intent (android.content.Intent)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 RootFW (com.spazedog.lib.rootfw3.RootFW)1 Preferences (com.spazedog.mounts2sd.tools.Preferences)1