// Path: library/src/main/java/com/felkertech/channelsurfer/utils/LiveChannelsUtils.java
// public class LiveChannelsUtils {
//     private static String TAG = "LiveUtils";
//     private static String ANDROID_TV_LIVE_CHANNELS = "com.google.android.tv";
//     private static String SONY_LIVE_CHANNELS = "com.sony.dtv.tvplayer";
//     public static Intent getLiveChannels(Activity mActivity) {
//         if(isPackageInstalled(ANDROID_TV_LIVE_CHANNELS, mActivity)) {
//             Intent i = mActivity.getPackageManager().getLaunchIntentForPackage(ANDROID_TV_LIVE_CHANNELS);
//             return i;
//         } else if(isPackageInstalled(SONY_LIVE_CHANNELS, mActivity)) {
//             Intent i = mActivity.getPackageManager().getLaunchIntentForPackage(SONY_LIVE_CHANNELS);
//             return i;
//         }
//         return null;
//     }
//     public static boolean hasLiveChannels(Activity mActivity) {
//         return getLiveChannels(mActivity) != null;
//     }
//     private static boolean isPackageInstalled(String packagename, Context context) {
//         PackageManager pm = context.getPackageManager();
//         try {
//             pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
//             return true;
//         } catch (PackageManager.NameNotFoundException e) {
//             return false;
//         }
//     }
// 
//     /**
//      Returns the TvInputProvider that was defined by the project's manifest
//      */
//     public static TvInputProvider getTvInputProvider(Context mContext, final TvInputProviderCallback callback) {
//         ApplicationInfo app = null;
//         try {
//             Log.d(TAG, mContext.getPackageName()+" >");
//             app = mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), PackageManager.GET_META_DATA);
//             Bundle bundle = app.metaData;
//             final String service = bundle.getString("TvInputService");
//             Log.d(TAG, service);
//             Log.d(TAG, mContext.getString(R.string.app_name));
//             try {
//                 Log.d(TAG, "Constructors: " + Class.forName(service).getConstructors().length);
// //                Log.d(TAG, "Constructor 1: " + Class.forName(service).getConstructors()[0].toString());
//                 new Handler(Looper.getMainLooper()).post(new Runnable() {
//                     @Override
//                     public void run() {
//                         TvInputProvider provider = null;
//                         try {
//                             provider = (TvInputProvider) Class.forName(service).getConstructors()[0].newInstance();
//                             Log.d(TAG, provider.toString());
//                             callback.onTvInputProviderCallback(provider);
//                         } catch (InstantiationException | IllegalAccessException | InvocationTargetException | ClassNotFoundException e) {
//                             e.printStackTrace();
//                         }
//                     }
//                 });
//             } catch(ClassNotFoundException e) {
//                 Log.e(TAG, e.getMessage());
//                 e.printStackTrace();
//             } catch(Exception e) {
//                 e.printStackTrace();
//             }
//         } catch (PackageManager.NameNotFoundException e) {
//             e.printStackTrace();
//         }
//         return null;
//     }
// 
//     public interface TvInputProviderCallback {
//         void onTvInputProviderCallback(TvInputProvider provider);
//     }
// }


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;
import com.felkertech.channelsurfer.utils.LiveChannelsUtils;
import com.crashlytics.android.Crashlytics;
import com.felkertech.settingsmanager.SettingsManager;
import io.fabric.sdk.android.Fabric;
package com.felkertech.sample.channelsurfer;




public class Launcher extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fabric.with(this, new Crashlytics());
        setContentView(R.layout.activity_launcher);
        findViewById(R.id.live).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
// Path: library/src/main/java/com/felkertech/channelsurfer/utils/LiveChannelsUtils.java
// public class LiveChannelsUtils {
//     private static String TAG = "LiveUtils";
//     private static String ANDROID_TV_LIVE_CHANNELS = "com.google.android.tv";
//     private static String SONY_LIVE_CHANNELS = "com.sony.dtv.tvplayer";
//     public static Intent getLiveChannels(Activity mActivity) {
//         if(isPackageInstalled(ANDROID_TV_LIVE_CHANNELS, mActivity)) {
//             Intent i = mActivity.getPackageManager().getLaunchIntentForPackage(ANDROID_TV_LIVE_CHANNELS);
//             return i;
//         } else if(isPackageInstalled(SONY_LIVE_CHANNELS, mActivity)) {
//             Intent i = mActivity.getPackageManager().getLaunchIntentForPackage(SONY_LIVE_CHANNELS);
//             return i;
//         }
//         return null;
//     }
//     public static boolean hasLiveChannels(Activity mActivity) {
//         return getLiveChannels(mActivity) != null;
//     }
//     private static boolean isPackageInstalled(String packagename, Context context) {
//         PackageManager pm = context.getPackageManager();
//         try {
//             pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
//             return true;
//         } catch (PackageManager.NameNotFoundException e) {
//             return false;
//         }
//     }
// 
//     /**
//      Returns the TvInputProvider that was defined by the project's manifest
//      */
//     public static TvInputProvider getTvInputProvider(Context mContext, final TvInputProviderCallback callback) {
//         ApplicationInfo app = null;
//         try {
//             Log.d(TAG, mContext.getPackageName()+" >");
//             app = mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), PackageManager.GET_META_DATA);
//             Bundle bundle = app.metaData;
//             final String service = bundle.getString("TvInputService");
//             Log.d(TAG, service);
//             Log.d(TAG, mContext.getString(R.string.app_name));
//             try {
//                 Log.d(TAG, "Constructors: " + Class.forName(service).getConstructors().length);
// //                Log.d(TAG, "Constructor 1: " + Class.forName(service).getConstructors()[0].toString());
//                 new Handler(Looper.getMainLooper()).post(new Runnable() {
//                     @Override
//                     public void run() {
//                         TvInputProvider provider = null;
//                         try {
//                             provider = (TvInputProvider) Class.forName(service).getConstructors()[0].newInstance();
//                             Log.d(TAG, provider.toString());
//                             callback.onTvInputProviderCallback(provider);
//                         } catch (InstantiationException | IllegalAccessException | InvocationTargetException | ClassNotFoundException e) {
//                             e.printStackTrace();
//                         }
//                     }
//                 });
//             } catch(ClassNotFoundException e) {
//                 Log.e(TAG, e.getMessage());
//                 e.printStackTrace();
//             } catch(Exception e) {
//                 e.printStackTrace();
//             }
//         } catch (PackageManager.NameNotFoundException e) {
//             e.printStackTrace();
//         }
//         return null;
//     }
// 
//     public interface TvInputProviderCallback {
//         void onTvInputProviderCallback(TvInputProvider provider);
//     }
// }


// Path: app/src/main/java/com/felkertech/sample/channelsurfer/launcher.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;
import com.felkertech.channelsurfer.utils.LiveChannelsUtils;
import com.crashlytics.android.Crashlytics;
import com.felkertech.settingsmanager.SettingsManager;
import io.fabric.sdk.android.Fabric;

package com.felkertech.sample.channelsurfer;




public class Launcher extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fabric.with(this, new Crashlytics());
        setContentView(R.layout.activity_launcher);
        findViewById(R.id.live).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = LiveChannelsUtils.getLiveChannels(Launcher.this);