RunAppOnStartupBroadcastReceiver.java
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Intermodalics All Rights Reserved.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 package eu.intermodalics.tango_ros_streamer.android;
00018 
00019 import android.content.BroadcastReceiver;
00020 import android.content.Context;
00021 import android.content.Intent;
00022 import android.content.SharedPreferences;
00023 import android.preference.PreferenceManager;
00024 
00025 import eu.intermodalics.tango_ros_streamer.R;
00026 import eu.intermodalics.tango_ros_streamer.activities.RunningActivity;
00027 
00028 public class RunAppOnStartupBroadcastReceiver extends BroadcastReceiver {
00029     @Override
00030     public void onReceive(Context context, Intent intent) {
00031         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
00032         boolean runAtBoot = sharedPreferences.getBoolean(context.getString(R.string.pref_run_at_device_boot_key), false);
00033         if (runAtBoot && intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
00034             Intent startRunningActivityIntent = new Intent(context, RunningActivity.class);
00035             startRunningActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
00036             context.startActivity(startRunningActivityIntent);
00037         }
00038     }
00039 }


TangoRosStreamer
Author(s):
autogenerated on Thu Jun 6 2019 19:49:57