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 ; }
Returns the TvInputProvider that was defined by the project s manifest