Your Utils
class does not have a method named getAssets()
. I assume you want to use the one from the Android Context
class. This means you need to have a Context
object to call getAssets()
. Without more details about your exact app design, I can't help you any further.
One possible solution is to create an Activity
subclass which all of your other activities extend. You also need to honor the activity life-cycle:
public abstract FontActivity extends Activity {
private Typeface font;
@Override
public onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
font = Typeface.createFromAsset(getAssets(), "fonts/font.ttf");
}
}
Now extend FontActivity
instead of Activity
.