1

This line always returns null. In this particular case the context is an activity. Any ideas are very much appreciated!

Edit

context.getApplicationContext().getApplicationInfo().name

Still returns null

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120

2 Answers2

1

Look at get application name from package name for the answer. The highest rated entry there worked for me.

Community
  • 1
  • 1
inder
  • 1,774
  • 1
  • 15
  • 15
0

In order to read android:name attribute in tag, you have to access ApplicationInfo.className field instead. Thus,

context.getApplicationContext().getApplicationInfo().className

will return what you expect.

FabianCook
  • 20,269
  • 16
  • 67
  • 115
Jiyong Park
  • 664
  • 3
  • 6