Is there any global activity on Android such that I put my code in that one activity, and it affects all activities in my project? This occurs to me because the same code is
You can create a class that extends Activity and then extend the CustomActivity to all the Activity Class like this.
public abstract class CustomActivity extends Activity{
public abstract void initComponents(); // you can create a abstract method
public abstract void addListner(); // you can create a abstract method
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
// your stuff here....
}
return true;
}
}
Now you can extend this class where you want to extend any class with Activity.