Intent.getIntExtra() behaviour changes on a virtual device and on a real device
I have the below code and on my computer via Eclipse virtual device it works fine. But when installed on a real life phone it always reverts to the else statement. This activity does not always get passed a value and if it is not I want a random record to appear. Thank you for any help or advice and time taken to read.
searchId = getIntent().getIntExtra("EMPLOYEE_ID", 0);
if(searchId > 0){
Query="SELECT * FROM " + DB_TABL开发者_如何学GoE +" ORDER BY RANDOM() LIMIT 1";
Log.v("STANDARD RANDOM", "Was run");
}
else{
Query ="SELECT * FROM " + DB_TABLE +" WHERE _id=" + searchId + "";
Log.v("FROM SEARCH PAGE", "Was run");
}
Not sure if this fixes your problem. But according to the documentation, your code is not correct:
The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Taken from Intent.putExtra.
You are using "EMPLOYEE_ID", without a package prefix, but you must include one!
精彩评论