getIntent()。getStringExtra(Intent.EXTRA_TEXT)具有相同的结果 [英] getIntent().getStringExtra(Intent.EXTRA_TEXT) has same result

查看:634
本文介绍了getIntent()。getStringExtra(Intent.EXTRA_TEXT)具有相同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与活动以下意向过滤器

 <activity
        android:name="com.extratexttest.MainActivity"
        android:label="@string/app_name" >
        <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.SEND" />

            <data android:mimeType="text/plain" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

和我检索这样的字符串从意图:

And I am retrieving the String like this from an Intent :

if (getIntent().hasExtra(Intent.EXTRA_TEXT))
    {
        String strResult = getIntent().getStringExtra(Intent.EXTRA_TEXT);
        Log.i("", "Received String : " + strResult);

    }

我第一次运行它的伟大工程的应用程序,我得到的价值。但是,下一次我做一个不同的字符串相同的动作,我得到了相同的结果。这似乎是它的某处缓存结果。如何清除缓存?

The first time I run the app it works great and I receive the value. However, the next time I do the same action on a different string I get the same result. It seems like its caching the result somewhere. How do I clear the cache?

编辑:这只有当我回去直通按钮近期任务按钮发生......当我preSS后退按钮它的伟大工程......

This only happens when I go back thru the button "recent task button"...When I press the back button it works great...

推荐答案

这添加到清单中,在机器人:标签=@字符串/ APP_NAME

android:launchMode="singleTop"

在活动中,重写这个方法:

In the activity, override this method:

@Override
public void onNewIntent(Intent intent) { 
    // Handle new intent here.
}

这篇关于getIntent()。getStringExtra(Intent.EXTRA_TEXT)具有相同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆