0

I need some assistance on my final capstone design project for my university. My question is, How can I develop an android studio code (Kotlin) for Facebook in order to show Live videos from a "Client" website? I already have a working code that shows the client's website, just need to be able to show his Live videos. This work is to finish my bachelor's degree in ELECTRICAL engineering, so no previous experience in programming apart from the C++ classes that I took 3 years ago.

This is the code i have now,

class FacebookActivity : AppCompatActivity() {
    private lateinit var callbackManager: CallbackManager

    /**
     *  This creates the page for Facebook login
     */
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_facebook)

        // Initialize the Facebook Login callback manager
        callbackManager = CallbackManager.Factory.create()

        // Register a callback for the Facebook Login button
        btnLogin.registerCallback(callbackManager, object : FacebookCallback<LoginResult> {
            // If the Facebook Login is successful
            override fun onSuccess(loginResult: LoginResult) {
                Log.d("FacebookActivity", "Facebook token: " + loginResult.accessToken.token)
                startFacebookPage()
            }

            // If the Facebook Login is cancelled
            override fun onCancel() {
                Log.d("FacebookActivity", "Facebook Login cancelled.")
            }

            // If there is an error during the Facebook Login
            override fun onError(error: FacebookException) {
                Log.d("FacebookActivity", "Facebook Login error: " + error.message)
            }
        })

        // Check if the user is already logged in to Facebook
        if (AccessToken.isCurrentAccessTokenActive()) {
            startFacebookPage()
        } else {
            // Log in the user with read permissions if they are not already logged in
            LoginManager.getInstance().logInWithReadPermissions(this, listOf("public_profile"))
        }
    }

    // Start the Facebook page
    private fun startFacebookPage() {
        val facebookIntent = Intent(Intent.ACTION_VIEW).apply {
            data = Uri.parse("https://www.facebook.com/radiodiosmedijonotecalles")
        }
        startActivity(facebookIntent)
    }

    /**
     * This allows to go "back"
     */
    override fun onSupportNavigateUp(): Boolean {
        onBackPressedDispatcher.onBackPressed()
        return true
    }
}

And the Manifest;

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.INTERNET" />

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:resizeable="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:enableOnBackInvokedCallback="true"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher2"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher2_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.RadioDiosMeDijoNoTeCalles"
        tools:targetApi="33">

        <activity
            android:name=".ClientActivity"
            android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
            android:exported="false" />
        <activity
            android:name=".AboutThisAppActivity"
            android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
            android:exported="false" />
        <activity
            android:name=".FacebookActivity"
            android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
            android:exported="true" />
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
        <meta-data
            android:name="com.facebook.sdk.ClientToken"
            android:value="@string/facebook_client_token" />

        <activity
            android:name=".ZenoRadioActivity"
            android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
            android:exported="false"
            android:screenOrientation="portrait"
            tools:ignore="LockedOrientationActivity" />
        <activity
            android:name=".YouTubeActivity"
            android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
            android:exported="false" />
        <activity
            android:name=".LinksActivity"
            android:exported="false" />
        <activity
            android:name=".TwitchActivity"
            android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
            android:exported="false" />
        <activity
            android:name=".DonationsActivity"
            android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
            android:exported="false" />
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Any and all Help will be greatly appreciated!

0 Answers0