Question

Je suis aux prises avec les éléments suivants comportement étrange de SingleTop activités.

J'ai défini quelques filtres d'intention dans cette activité:

<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>

Ce code doit commencer l'activité:

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);    

        }

    });

dans le onResume de la DashboardActivity-je vérifier pour la fonction d'action:

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);
}

Mais lorsque j'exécute ce code, j'ai toujours le android.intent.action.MAIN d'action.Si je supprime le singleTop mode de lancement, il lance une nouvelle activité, mais elle passe à la bonne intention.J'ai utiliser la même instance de l'activité, de sorte singleTop, singleTask ou singleInstance doit faire le travail.Mais je ne sais pas ce qui ne va pas ici.À l'AIDE!

Était-ce utile?

La solution

Intent.ACTION_VIEW.equals(intent.getAction())

Où est-ce l'intention de venir?Afin de capturer la nouvelle Intention, vous devez utiliser onNewIntent().

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top