Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. PackageInfo pinfo;
  2. try {
  3. pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
  4. } catch (NameNotFoundException e1) {
  5. // TODO Auto-generated catch block
  6. e1.printStackTrace();
  7. pinfo = null;
  8. }
  9.  
  10. appVersion = pinfo.versionCode;
  11.  
  12. public class NonActivityClass implements SensorListener{
  13. Context mContext;
  14. public NonActivtiyClass(Context context) {
  15. this.mContext = context;
  16. }
  17. //Rest of your code
  18. }
  19.  
  20. NonActivityClass nac = new NonActivityClass(this);
  21.  
  22. public int getAppVersionCode() {
  23. return BuildConfig.VERSION_CODE;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement