Android get current package name 

Joined:
07/27/2010
Posts:
130

April 21, 2011 10:59:37    Last update: April 21, 2011 10:59:37
The class android.content.Context (of which 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())
			);
}
Share |
| Comment  | Tags