Android Question Get my app package name

Noob question: how can i save my app's package name in a string variable?

If your Package-Name is "com.myapp"
In MainActivity insert...

Code: Copy
Sub Process_Globals

   Dim PName as String : PName = "com.myapp"

End Sub

To use your Variable from Main Activity...

Code: Copy
Sub Fill_Label

   myLabel.Text = PName

End Sub

To use your Variable from any other Activity...

Code: Copy
Sub Fill_Label

   myLabel.Text = Main.PName

End Sub
 
Upvote 0
Upvote 0
Maybe a function like could help:

Code: Copy
Sub GetPackageName As String
  Dim r As Reflector
  Return r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
End Sub
It uses the Reflection library.
 
Upvote 0
Thanks.yes i need to extract package name from manifest/apk running the code, i would like to protect my app from decompiling/recompiling and reskin

@holdemadvantage
How has it worked out? I assume you encrypted the string you were comparing against the package name returned.
 
Upvote 0
Back
Top