Android get current package name
April 21, 2011 10:59:37 Last update: April 21, 2011 10:59:37
The class android.content.Context (of which
Sample code:
android.app.Activity is a subclass) provides the method getPackageName() which returns the name of this application's package.
Sample code:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView question = (TextView) findViewById(R.id.question); question.setText(String.format( getString(R.string.question), getPackageName()) ); }