1

I have a android code base which contain project for Android TV and Android mobile. It play basically radio, it also support play on near. Now the requirement is that this app should run on Android wear Android Auto.

I have not idea what should I do next change this code base for support Android auto and Android wear.

Should I create another project of wear and auto or existing project can be modified, If existing project can be supportable for wear and auto, can you please tell me steps or share me link which can I follow to make my project supportable in auto and wear.

Below is my existing menifest file

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

    <supports-screens android:smallScreens="false"
        android:normalScreens="false"
        android:largeScreens="true"
        android:xlargeScreens="true"/>
    <uses-feature
        android:name="android.software.leanback"
        android:required="true" />
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"
        tools:ignore="LeanbackUsesWifi" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <!-- Needed only if your app looks for Bluetooth devices.
             If your app doesn't use Bluetooth scan results to derive physical
             location information, you can strongly assert that your app
             doesn't derive physical location. -->
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <!-- Needed only if your app makes the device discoverable to Bluetooth
      devices. -->
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
    <!-- Needed only if your app communicates with already-paired Bluetooth
           devices. -->
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <!--bibo01 : hardware option-->
    <uses-feature android:name="android.hardware.bluetooth" android:required="false"/>
    <uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>


    <queries>
        <package android:name="com.montrealgreektv.app.player" />
    </queries>

    <application
        android:name=".application.App"
        android:allowBackup="true"
        android:banner="@mipmap/ic_banner"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MontrealGreek"
        android:usesCleartextTraffic="true"
        tools:ignore="GoogleAppIndexingWarning"
        tools:targetApi="31">
        <activity
            android:name=".tv.TvPlayerActivity"
            android:exported="false" />
        <activity
            android:name=".tv.TvMainActivity"
            android:exported="false" />
        <activity
            android:name=".tv.TvSplashActivity"
            android:exported="false"
            android:screenOrientation="landscape">

            <!-- <intent-filter> -->
            <!-- <action android:name="android.intent.action.MAIN" /> -->


            <!-- <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> -->
            <!-- </intent-filter> -->
        </activity>
        <activity
            android:name=".news.NewsActivity"
            android:exported="false"
            android:label="@string/title_activity_news"
            android:theme="@style/Theme.MontrealGreek.NoActionBar" />
        <activity
            android:name=".radio.RadioPlayerActivity"
            android:exported="false" />
        <activity
            android:name=".player.PlayerActivity"
            android:exported="true"
            android:launchMode="singleTask"
            android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>
        <activity
            android:name=".home.MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="montrealgreektv" />
            </intent-filter>
        </activity>
        <activity
            android:name=".home.SplashActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".radio.DeviceListDialogFragment"
            android:exported="false"
            android:screenOrientation="portrait"/>

        <meta-data
            android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
            android:value="com.montrealgreektv.app.player.CastOptionsProvider" />

        <service android:name=".service.MyService" />

        <uses-library
            android:name="org.apache.http.legacy"
            android:required="false" />
    </application>

</manifest>

My gradle code

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.montrealgreektv.app'
    compileSdk 33

    defaultConfig {
        applicationId "com.montrealgreektv.app"
        minSdk 23
        targetSdk 33
        //for mobile
//        versionCode 8
//        versionName "1.02"

        //for TV
        versionCode 9
        versionName "1.03"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }

    dataBinding {
        enabled = true
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    //noinspection GradleCompatible
    implementation 'com.android.support.constraint:constraint-layout:2.0.4'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.6.0'
    implementation 'androidx.navigation:navigation-ui-ktx:2.6.0'
    implementation 'androidx.leanback:leanback:1.0.0'
    testImplementation 'junit:junit:4.13.2'
   
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'


    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.intuit.sdp:sdp-android:1.1.0'

    // LiveData and ViewModel
    implementation "androidx.lifecycle:lifecycle-common-java8:2.1.0"
    implementation "androidx.lifecycle:lifecycle-extensions:2.1.0"

    // RxJava
    implementation 'io.reactivex.rxjava2:rxjava:2.2.15'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'

    // Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    // Gson Converter
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    // Glide
    implementation 'com.github.bumptech.glide:glide:4.14.2'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'

    implementation 'com.google.android.exoplayer:exoplayer:2.18.2'
    implementation 'com.google.android.exoplayer:exoplayer-dash:2.18.2'
    implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.18.2'
    implementation 'com.google.android.exoplayer:exoplayer-core:2.18.2'
    implementation 'com.google.android.exoplayer:exoplayer-hls:2.18.2'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.18.2'
    implementation 'com.google.android.exoplayer:extension-cast:2.18.2'

    implementation 'com.github.bumptech.glide:glide:4.14.2'
    implementation 'androidx.mediarouter:mediarouter:1.2.5'

    implementation 'androidx.leanback:leanback:1.0.0'
}

Please guide me to make this code supportable for auto and wear

Shailesh Kumar
  • 393
  • 5
  • 20

1 Answers1

0

For Auto, check out Build media apps for cars and Add support for Android Auto. For Wear, check out the Wear Media gallery.

Ben Sagmoe
  • 440
  • 2
  • 9