-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8b1959
commit cec70b6
Showing
7 changed files
with
89 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
bone/src/main/java/com/idogfooding/bone/utils/AppInfoUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.idogfooding.bone.utils; | ||
|
||
import android.content.Context; | ||
import android.content.pm.PackageInfo; | ||
|
||
/** | ||
* AppInfoUtils | ||
* | ||
* @author Charles | ||
*/ | ||
public class AppInfoUtils { | ||
|
||
/** | ||
* get package info | ||
* @param context | ||
* @return | ||
*/ | ||
public static PackageInfo getPackageInfo(Context context) { | ||
try { | ||
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* get package name | ||
*/ | ||
public static String getPackageName(Context context) { | ||
try { | ||
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).packageName; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return ""; | ||
} | ||
} | ||
|
||
/** | ||
* get the current version name | ||
*/ | ||
public static String getVersionName(Context context) { | ||
try { | ||
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return ""; | ||
} | ||
} | ||
|
||
/** | ||
* get the current versionCode | ||
*/ | ||
public static int getVersionCode(Context context) { | ||
try { | ||
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
bone/src/main/java/com/idogfooding/bone/utils/VersionUtils.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters