El enlace profundo de Android no funciona si la aplicación se abre mediante vínculo profundo ya

El enlace profundo no funciona si la aplicación ya está abierta por vínculo profundo.

Sin embargo, si abro la aplicación no activando un deeplink, como hacer clic en el icono de la aplicación para abrir la aplicación. Entonces activar deeplink después funcionaría siempre.


Aquí vienen los detalles:

Así que tengo mi actividad configurada como esta en AndroidManifest, a saber, LaunchActivity.

<activity android:name="some.package.name.LaunchActivity" android:screenOrientation="portrait" android:theme="@style/Theme.SomeTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <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="dlscheme" android:host="dlhost" /> </intent-filter> </activity> 

Y en LaunchActivity, imprimiría un registro onCreate () para indicar que ha estado allí.

solía

 adb shell am start -W -a android.intent.action.VIEW -d "dlscheme://dlhost/param" some.package.name 

para probar el enlace profundo.

Con la aplicación muerta, he utilizado el comando anterior. Puede abrir la aplicación y la ruta a la actividad correcta, no hay problema. Y tienen el siguiente registro.

 adb shell am start -W -a android.intent.action.VIEW -d "dlscheme://dlhost/param" some.package.name Starting: Intent { act=android.intent.action.VIEW dat=dlscheme://dlhost/param pkg=some.package.name } Status: ok Activity: some.package.name/.activity.LaunchActivity ThisTime: 898 TotalTime: 898 WaitTime: 919 Complete 

Sin embargo, si vuelvo a introducir el mismo comando, sin matar la aplicación. Sólo abriría la aplicación, pero no abrirá la actividad correcta y producirá el siguiente registro.

 adb shell am start -W -a android.intent.action.VIEW -d "dlscheme://dlhost/param" some.package.name Starting: Intent { act=android.intent.action.VIEW dat=dlscheme://dlhost/param pkg=some.package.name } Warning: Activity not started, its current task has been brought to the front Status: ok Activity: some.package.name/.activity.LaunchActivity ThisTime: 0 TotalTime: 0 WaitTime: 6 Complete 

con esta línea extra

 Warning: Activity not started, its current task has been brought to the front 

En realidad, también he intentado esto con un sitio web, con esta intención de cromo:

 intent://dlhost/param#Intent;scheme=dlscheme;package=some.package.name;end 

y se comportaría igual.

Añadir android:launchMode="singleTop" en manifiesto en las etiquetas de actividad de LaunchActivity

Encontré que la adición de android:launchMode="singleTask" funciona. singleTop no funcionó para mí.

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recipe); onNewIntent(getIntent()); } protected void onNewIntent(Intent intent) { String action = intent.getAction(); String data = intent.getDataString(); if (Intent.ACTION_VIEW.equals(action) && data != null) { String recipeId = data.substring(data.lastIndexOf("/") + 1); Uri contentUri = RecipeContentProvider.CONTENT_URI.buildUpon() .appendPath(recipeId).build(); showRecipe(contentUri); } } 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.