Android : 여러 가지 의도 필터가있는 싱글 탑 동작
-
21-12-2019 - |
문제
나는 싱글거 활동의 다음과 같은 이상한 행동으로 고투하고 있습니다.
i는 그 활동에 몇 가지 의도 필터를 정의했습니다 :
<activity android:name="com.example.DashboardActivity"
android:screenOrientation="landscape"
android:launchMode="singleTop"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="video" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.EDIT" />
<data android:scheme="survey" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.CALL" />
<data android:scheme="call" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
.
이 코드는 활동을 시작해야합니다.
webView.setWebViewClient(new WebViewClient()
{
public boolean shouldOverrideUrlLoading(WebView view, String url) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
return true;
} catch(ActivityNotFoundException e) {
Log.e(TAG,"Could not load url"+url);
}
return super.shouldOverrideUrlLoading(view, url);
}
});
.
dashboardActivity의 onresume에서는 다음과 같은 조치를 확인합니다.
public void onResume(){
super.onResume();
Fragment fragment = null;
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
extras.putParcelable("uri", getIntent().getData());
fragment = new VideoplayerFragment();
} else {
fragment = new DashboardFragment();
}
addOrReplaceFragment(fragment, extras);
}
.
그러나이 코드를 실행하면 항상 android.intent.action.MAIN
동작을 얻습니다.singleTop
실행 모드를 제거하면 새로운 활동을 시작하지만 올바른 의도를 전달합니다.나는 활동의 동일한 인스턴스를 사용해야하므로 singleTop
, singleTask
또는 singleInstance
가 작업을 수행해야합니다.그러나 여기서 뭔지가 무엇인지 모르겠습니다.도움!
해결책
Intent.ACTION_VIEW.equals(intent.getAction())
.
이 의도는 어디에서 오는가?새로운 의도를 잡기 위해서는 당신이 사용해야합니다. onnewintent () . <./ P>
제휴하지 않습니다 StackOverflow