Je travaille sur les liens Firebase Dynamic depuis hier.Aucun lien profond trouvé si je modifie le placement du filtre d'intention
Ceci est mon activité principale:
private GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(AppInvite.API)
.build();
boolean autoLaunchDeepLink = true;
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
.setResultCallback(
new ResultCallback<AppInviteInvitationResult>() {
@Override
public void onResult(@NonNull AppInviteInvitationResult result) {
if (result.getStatus().isSuccess()) {
try {
deepLink = URLDecoder.decode(deepLink, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Uri uri = Uri.parse(deepLink);
// String requestId = uri.getQueryParameter("requestID");
String requestId2 = uri.getQueryParameter("extra1");
Log.v("EXTRA PARAMETER ",requestId2);
if(requestId2 == "value") {
intent = new Intent(getApplicationContext(), Main2Activity.class);
startActivity(intent);
}
// ...
} else {
Log.d("string ", "getInvitation: no deep link found.");
}
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Uri BASE_URI = Uri.parse("http://example.com/");
Uri APP_URI = BASE_URI.buildUpon().
appendQueryParameter("extra1", "value").build();
String encodedUri = null;
try {
encodedUri = URLEncoder.encode(APP_URI.toString(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Uri deepLink = Uri.parse("https://eh62u.app.goo.gl/y6N7/?link="+encodedUri);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, "");
intent.putExtra(Intent.EXTRA_SUBJECT, "GET TICKETS");
intent.putExtra(Intent.EXTRA_TEXT, "Click here to get the booked tickets: " + deepLink);
startActivity(Intent.createChooser(intent, "Send Email"));
}
});
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {}
}
Je voulais commencer Main2Activity en utilisant l'intention lorsque le lien profond a été cliqué. manifeste Android:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<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:host="example.com"
android:scheme="https"/>
</intent-filter>
</activity>
<activity android:name=".Main2Activity">
</activity>
</application>
Maintenant, si je mets le filtre à l'intention de lien profond dans Main2Activity, quand je clique sur le lien, elle ouvre directement Main2Activity et ne va pas dans l'activité principale et onResult n'est pas appelé. Mais maintenant que j'ai mis le filtre d'intention dans l'activité principale, il n'y a pas de lien profond trouvé.
La classe Main2Activity n'a absolument rien dedans – L3G3NDj