You never want to instantiate an Activity
this way
DataTrak dt = new DataTrak();
they are not like a normal Java class. Only do it with startActivity()
. What you could do is pass an extra to the Activity
and check it there. Something like
Intent i = new Intent(v.getContext(), DataTrak.class);
i.putExtra("someKey", true); // where someKey is any key you want to use
startActivity(i);
Then in onCreate()
or onResume()
of your DataTrak
Activity
(depending on if you have finished it) check that value
Intent i = getIntent();
boolean enable = i.getBooleanExtra("someKey", false); // false for default value
btn_grand.setEnabled(enable); // if you passed the value it will enable else is disabled