开发者

Intent.getIntExtra() behaviour changes on a virtual device and on a real device

开发者 https://www.devze.com 2023-03-18 15:01 出处:网络
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.

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号