Ich arbeite seit gestern an Firebase Dynamic Links.Kein Deep Link gefunden, wenn ich die Intent-Filterplatzierung ändere
Das ist meine Haupttätigkeit:
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) {}
}
Ich war Main2Activity mit Absicht, wenn der tiefe Link geklickt starten wollte. Android Manifest:
<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>
Nun, wenn ich die tiefe Verbindung Intent-Filter in Main2Activity setzen, wenn ich auf den Link klicken, es öffnet sich direkt Main2Activity und geht nicht in Hauptaktivität und onResult wird nicht aufgerufen. Aber jetzt, da ich den Intentfilter in Hauptaktivität gesetzt habe, heißt es noch kein Deep Link gefunden.
Main2Activity Klasse hat absolut nichts drin – L3G3NDj