私は2つのアプリケーションA &を持っています。アプリケーションBでは、深いリンクとstartActivityForResult()
を使用してアプリケーションBのアクティビティを開きます。返品、ちょうど受け取ったアプリA RESULT_CANCELED
!私の最初の質問は、「別のアプリを開くためにDeep Linkを使用すると結果を返すことは可能ですか?」であり、そうであれば私のミスはどこですか?アプリケーションBでディープリンクを使用して別のアプリケーションを開くときの結果を返します
私のマニフェスト、:アプリケーションAでは
<activity android:name=".activity.TargetActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<!-- note that the leading "/" is required for pathPrefix-->
<data
android:host="www.example.com"
android:pathPrefix="/gizmos"
android:scheme="http" />
<data
android:host="www.example.com"
android:pathPrefix="/gizmos"
android:scheme="https" />
<data
android:host="example.com"
android:pathPrefix="/gizmos"
android:scheme="http" />
<data
android:host="example.com"
android:pathPrefix="/gizmos"
android:scheme="https" />
</intent-filter>
</activity>
:また
Uri webpage = Uri.parse("android-app://com.vancosys.payment/http/www.example.com/gizmos?name=FMarket&id=4231");
Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage);
// Verify it resolves
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(webIntent, 0);
boolean isIntentSafe = activities.size() > 0;
// Start an activity if it's safe
if (isIntentSafe)
{
// '4231' is my request code
startActivityForResult(webIntent, 4231);
}
:アプリケーションBで
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode == 4231)
{
if (resultCode == RESULT_OK)
{
String id = data.getStringExtra("ID");
Intent i = new Intent(this, ResultActivity.class);
i.putExtra("RESULT", true);
i.putExtra("ID", id);
startActivity(i);
}
else
{
// It JUST equals to RESULT_CANCELED!!!
Intent i = new Intent(this, ResultActivity.class);
i.putExtra("result", false);
startActivity(i);
}
}
}
そして最後に、:
new Handler().postDelayed(new Runnable()
{
public void run()
{
Intent i = new Intent();
TargetActivity.this.setResult(RESULT_OK, i);
i.putExtra("ID", "45651232");
finish();
}
}, 3000);
更新日: Intent data
:onActivityResult()
はnull
です!!!
ハズレを支援します!働いていない。返された意図はnullで結果コードはRESULT_CANCELEDです... – YUSMLE
このハンドラが呼び出されたかどうかをチェックします。結果を設定せずにApp Bを閉じることができるかどうか確認します。 –