Java Code Examples for android.content.Intent.ACTION_BOOT_COMPLETED

The following are Jave code examples for showing how to use ACTION_BOOT_COMPLETED of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: PrivacyStreams   File: DeviceEventUpdatesProvider.java   View Source Code Vote up 9 votes
@Override
public void onReceive(Context context, Intent intent) {
    String event = null;
    String type = null;

    switch(intent.getAction()){
        case Intent.ACTION_SCREEN_OFF:
            event = DeviceEvent.EVENT_SCREEN_OFF;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_SCREEN_ON:
            event = DeviceEvent.EVENT_SCREEN_ON;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_USER_PRESENT:
            event = DeviceEvent.EVENT_SCREEN_USER_PRESENT;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_BOOT_COMPLETED:
            event = DeviceEvent.EVENT_BOOT_COMPLETED;
            type = DeviceEvent.TYPE_BOOT;
            break;

        case Intent.ACTION_SHUTDOWN:
            event = DeviceEvent.EVENT_BOOT_SHUTDOWN;
            type = DeviceEvent.TYPE_BOOT;
            break;

        case Intent.ACTION_BATTERY_LOW:
            event = DeviceEvent.EVENT_BATTERY_LOW;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_BATTERY_OKAY:
            event = DeviceEvent.EVENT_BATTERY_OKAY;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_POWER_CONNECTED:
            event = DeviceEvent.EVENT_BATTERY_AC_CONNECTED;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_POWER_DISCONNECTED:
            event = DeviceEvent.EVENT_BATTERY_AC_DISCONNECTED;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case AudioManager.RINGER_MODE_CHANGED_ACTION:
            AudioManager am = (AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE);
            switch (am.getRingerMode()) {
                case AudioManager.RINGER_MODE_SILENT:
                    event = DeviceEvent.EVENT_RINGER_SILENT;
                    type = DeviceEvent.TYPE_RINGER;
                    break;

                case AudioManager.RINGER_MODE_VIBRATE:
                    event = DeviceEvent.EVENT_RINGER_VIBRATE;
                    type = DeviceEvent.TYPE_RINGER;
                    break;

                case AudioManager.RINGER_MODE_NORMAL:
                    event = DeviceEvent.EVENT_RINGER_NORMAL;
                    type = DeviceEvent.TYPE_RINGER;
                    break;
            }
        default:
            break;
    }

    if (type != null)
        output(new DeviceEvent(type, event));
}
 
Example 2
Project: SmingZZick_App   File: AttackReciver.java   View Source Code Vote up 7 votes
@Override
public void onReceive(Context context, Intent intent) {
    // TODO: This method is called when the BroadcastReceiver is receiving
    // an Intent broadcast.
    String action = intent.getAction();

    switch (action) {
        case ACTION_ATTACK_NOTI :
            notiAttack(context, intent);
            return;
        case ACTION_SMING_NOTI :
            notiMakeTime(context, intent);
            return;
        case ACTION_ATTACK_NOTI_CLICK :
            clickAttackNoti(context, intent);
            return;
        case Intent.ACTION_BOOT_COMPLETED :
        case Intent.ACTION_MY_PACKAGE_REPLACED :
            AttackManager.getInstance().clearMakeTimeNoti(context);
            AttackManager.getInstance().registMakeTimeNoti(context);
            AttackManager.getInstance().refreshAttackAlarm(context);
            return;
    }
    throw new UnsupportedOperationException("Not yet implemented");
}
 
Example 3
Project: home-assistant-Android   File: LocationUpdateReceiver.java   View Source Code Vote up 7 votes
@Override
public void onReceive(Context context, Intent intent) {
    prefs = Utils.getPrefs(context);
    switch (intent.getAction()) {
        case Intent.ACTION_BOOT_COMPLETED:
        case ACTION_START_LOCATION:
            tempContext = context;
            apiClient = new LostApiClient.Builder(context)
                    .addConnectionCallbacks(this)
                    .build();

            apiClient.connect();
            break;
        case ACTION_LOCATION_UPDATE:
            if (prefs.getBoolean(Common.PREF_ENABLE_LOCATION_TRACKING, false) && LocationResult.hasResult(intent)) {
                LocationResult result = LocationResult.extractResult(intent);
                Location location = result.getLastLocation();
                if (location != null)
                    logLocation(location, context);
            }
            break;
    }
}
 
Example 4
Project: home-assistant-Android   File: LocationUpdateReceiver.java   View Source Code Vote up 7 votes
@Override
public void onReceive(Context context, Intent intent) {
    prefs = Utils.getPrefs(context);
    switch (intent.getAction()) {
        case Intent.ACTION_BOOT_COMPLETED:
        case ACTION_START_LOCATION:
            apiClient = new GoogleApiClient.Builder(context)
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .addApi(LocationServices.API)
                    .build();

            apiClient.connect();
            break;
        case ACTION_LOCATION_UPDATE:
            if (prefs.getBoolean(Common.PREF_ENABLE_LOCATION_TRACKING, false) && LocationResult.hasResult(intent)) {
                LocationResult result = LocationResult.extractResult(intent);
                Location location = result.getLastLocation();
                if (location != null)
                    logLocation(location, context);
            }
            break;
    }
}
 
Example 5
Project: InitialVolume   File: Service.java   View Source Code Vote up 7 votes
@Override
public void onReceive(Context context, Intent intent) {
    SharedPreferences prefs;
    switch (intent.getAction()) {
        case Intent.ACTION_BOOT_COMPLETED:
            IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
            context.getApplicationContext().registerReceiver(this, filter);
            prefs = PreferenceManager.getDefaultSharedPreferences(context);
            if (prefs.getBoolean(context.getString(R.string.pref_set_on_boot), false)) {
                setVolume(context);
            }
            break;
        case Intent.ACTION_SCREEN_ON:
            prefs = PreferenceManager.getDefaultSharedPreferences(context);
            if (prefs.getBoolean(context.getString(R.string.pref_set_on_screen_on), false)) {
                setVolume(context);
            }
            break;
    }
}
 
Example 6
Project: JobSchedulerCompat   File: JobGcReceiverTest.java   View Source Code Vote up 6 votes
@Test
public void testBootReceiverRegistered() {
    Intent intent = new Intent(Intent.ACTION_BOOT_COMPLETED);
    AndroidManifest manifest = ShadowApplication.getInstance().getAppManifest();
    List<BroadcastReceiver> receivers = ShadowApplication.getInstance().getReceiversForIntent(intent);
    assertThat(receivers, hasItem(isA(JobGcReceiver.class)));
}
 
Example 7
Project: OpenHomeAnalysis   File: OhaBroadcast.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case START_SYNC_ENERGY_USE:
            OhaSyncService.start(context);
            return;
        case Intent.ACTION_BOOT_COMPLETED:
            OhaSyncService.start(context);
            return;
        case ConnectivityManager.CONNECTIVITY_ACTION:
            OhaSyncService.start(context);
            return;

    }
}
 
Example 8
Project: anitrend-app   File: NotificationRunner.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case Intent.ACTION_BOOT_COMPLETED:
            if(new ApplicationPrefs(context).isAuthenticated()) {
                if (new DefaultPreferences(context).isNotificationEnabled())
                    new ServiceScheduler(context).scheduleJob();
                else
                    new ServiceScheduler(context).cancelJob();
            }
            break;
    }
}
 
Example 9
Project: Dendroid-HTTP-RAT   File: MyService.java   View Source Code Vote up 6 votes
@Override
public void onCreate() {
     IntentFilter filterBoot = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
     filterBoot.addAction(Intent.ACTION_SCREEN_OFF);
     mReceiver = new ServiceReceiver();
     registerReceiver(mReceiver, filterBoot);
     super.onCreate();
      	PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putLong("inacall", 0).commit();
}
 
Example 10
Project: StartBluetooth   File: Service.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case Intent.ACTION_BOOT_COMPLETED:
            IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
            context.getApplicationContext().registerReceiver(this, filter);
            setBluetooth(context, R.string.pref_set_on_boot);
            break;
        case Intent.ACTION_SCREEN_ON:
            setBluetooth(context, R.string.pref_set_on_screen_on);
            break;
    }
}
 
Example 11
Project: leanback-homescreen-channels   File: LauncherNotificationReceiver.java   View Source Code Vote up 5 votes
@Override
public void onReceive(Context context, Intent intent) {

    Bundle extras = intent.getExtras();

    switch (intent.getAction()) {
        case TvContractCompat.ACTION_PREVIEW_PROGRAM_BROWSABLE_DISABLED:
            // Notice that the user has removed a preview program.
            // The app should remove the program from the channel and should never publish it
            // again. The app could use this as an indication that the user is no longer
            // interested in watching this type of content.
            Log.d(TAG, "preview program browsable disabled");
            break;
        case TvContractCompat.ACTION_WATCH_NEXT_PROGRAM_BROWSABLE_DISABLED:
            // Notice that the user has removed a program from the watch next list.
            Log.d(TAG, "watch next program browsable disabled");
            break;
        case TvContractCompat.ACTION_PREVIEW_PROGRAM_ADDED_TO_WATCH_NEXT:
            // Notice that the user has added a preview program to their watch next list. Use
            // this information to update internal data structures or as an indication of the
            // user's interest in this type of programming.
            // From that point on, the app is responsible for this program and should treat it
            // like other programs in a channel.
            Log.d(TAG, "preview program added to watch next   preview " +
                    extras.getString(TvContractCompat.EXTRA_PREVIEW_PROGRAM_ID)
                    + "  watch-next "
                    + extras.getString(TvContractCompat.EXTRA_WATCH_NEXT_PROGRAM_ID));
            break;
        case Intent.ACTION_BOOT_COMPLETED:
            // Notice that the device has just finished booting. Use this opportunity to publish
            // the initial list of channels to the launcher. This intent is useful for the
            // preinstalled apps on the device. Apps that can be installed from the Play Store
            // should use ACTION_INITIALIZE_PROGRAMS as the signal to start posting their
            // channels.
            Log.d(TAG, "ACTION_BOOT_COMPLETED received");
            break;
        case TvContractCompat.ACTION_INITIALIZE_PROGRAMS:
            // Notice that the app was just installed from the Play Store. Use this opportunity
            // to publish the initial list of channels to the launcher. This intent is useful
            // for apps that don't come "pre-installed" and are installed via Play Store.
            Log.d(TAG, "ACTION_INITIALIZE_PROGRAMS received");
            break;
    }
}