How Do I Get Extra From An Intent (as A Type Long)?
I have this problem accessing an extra from an intent. The value i'm parsing is a long type, and I need this value to be stored in a database. So this is what I have so far: MainAc
Solution 1:
Move fetchDate = getIntent();
inside onCreate
method of Activity as:
protectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.create);
//.your code here..
fetchDate = getIntent(); // get intent here from previous ActivitylongdateFecth= fetchDate.getLongExtra(DATE, defaultValue);
}
Solution 2:
First check - Value is associated with the given name. if you don't want to use defaultValue try with bundle as follow
if (getchDate.hasExtra("Date")) {
Bundle bundle = newBundle();
bundle = getchDate.getExtras();
Objectobject = bunlde.get(Date);
Now parse thisobjectin your desire type.
}
Post a Comment for "How Do I Get Extra From An Intent (as A Type Long)?"