Wednesday, 13 February 2019

How to launch app from deeplink in Android TV and Android xiaomi TV

From deep-link or from notification when we r launching any app than after go back from that screen if we have to show home screen of application than we have to do following thing:-

1. Open Splash Screen and do the following this code is for xiaomi tv deeplink:
Intent deepLinkIntent = getIntent();
if (deepLinkIntent == null) {
    Log.d("SplashActivity", "deepLink  intent is null: ");

} else {
    Log.d("SplashActivity", "deepLink  intent getExtras: " + deepLinkIntent);
    String str = deepLinkIntent.toString();
    if (str.contains("dat=yourAppName://asset/")) {
        String s1 = "dat=yourAppName://asset/";
        int index = str.indexOf(s1);
        if (index != -1) {
            int index2 = str.indexOf(" ", index);
            deepLinkAssetId = str.substring(index + 17, index2);
            Log.d("SplashActivity", str.substring(index + 17, index2));
        }
    }
}
2. open menifest file :- 
         <activity
    android:name=".show.ui.activity.ShowDetailsActivity"
    android:theme="@style/DetailPageTheme">
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value=".home.ui.activity.HomeActivity"/>
</activity>

 3.  Now Go the SplashScreen and write following code to navigate from respective screen :-
Intent intent = new Intent(SplashActivity.this,ShowDetailsActivity.class);
intent.putExtras(bundle);//if any bundle or data require in respective screen than needs to send the same..
TaskStackBuilder.create(SplashActivity.this).addNextIntentWithParentStack(intent).startActivities();
finish();

No comments:

Post a Comment