Android的意图getExtras()导致的Avast报警 [英] Android Intent getExtras() causes Avast Alarm
问题描述
我想打电话给一个活动,并通过两个值给它,一个字符串和一个整数。
I'm trying to call an Activity and pass two values to it, a string and a integer.
我通过测试USB调试与使用Eclipse中的Android SDK。问题是,当我启动我的设备上的应用程序突然从我的Avast的应用程序得到一个警告(一些关于我的应用程序被恶意程序 - 安卓代理的ACH [PUP])。我测试了不同的设备,这是相同的无处不在
I'm using the Android SDK with eclipse via USB debugging for testing. The thing is, when I launch the app on my device I suddenly get a warning from my Avast app (something about my app being an unwanted program - android:Agent-ACH [PUP]). I tested different devices, it's the same everywhere
这是code调用活动:
This is the code to call the activity:
Intent ch = new Intent(context, ActivityChaos.class);
ch.putExtra("cards", Data.getNextCardsString(1, false));
ch.putExtra("ID", ID);
context.startActivityForResult(ch, ID);
这是从所谓的活动:
And this is from the called activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chaos);
Bundle extra = getIntent().getExtras();
String s = extra.getString("cards");
// int ID = extra.getInt("ID");
...
}
最后一行extra.getInt(ID)是导致报警,一旦它的注释是没有问题的人。
The last line extra.getInt("ID") is the one that causes the alarm, once its commented out there is no problem.
我是什么做错了吗?
这只是虚惊一场,或这是怎么回事?
它是这样一个基本的东西...
What am I doing wrong? Is this just a false alarm or what's going on? It's such a basic thing...
推荐答案
在该方法context.startActivityForResult(CH,ID):如果ID为> = 0,code将在返回的onActivityResult()的时候活动退出。
On the method context.startActivityForResult(ch, ID): if ID is >= 0, this code will be returned in onActivityResult() when the activity exits.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bundle extra = getIntent().getExtras();
String s = extra.getString("cards");
int ID = extra.getInt("ID");
}
来源: http://developer.android.com/reference/android/应用程序/ Activity.html
这篇关于Android的意图getExtras()导致的Avast报警的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!